1: class Aplicacion
2: {
3: public static void Main()
4: {
5: // Simulamos los datos que podríamos extraer de
6: // una tabla de asignación
7: // Formato: <keyProveedor,keyDb>
8: Dictionary<string, string> tabla =
9: new Dictionary<string, string>();
10: tabla.Add("SUELDO", "Personal");
11: tabla.Add("CENA_NAVIDAD", "GastosVarios");
12: tabla.Add("PC", "Maquinaria");
13: tabla.Add("IMPRESORA", "Maquinaria");
14: tabla.Add("PROPINA_INFORMATICO", "GastosVarios");
15:
16: // Simulamos también un fichero leído del proveedor
17: // Formato: <keyProveedor,importe>
18: KeyValuePair<string, double>[] datos = new KeyValuePair<string,double>[5];
19: datos[0] = new KeyValuePair<string, double>("PC", 1200);
20: datos[1] = new KeyValuePair<string, double>("IMPRESORA", 600);
21: datos[2] = new KeyValuePair<string, double>("SUELDO", 1200);
22: datos[3] = new KeyValuePair<string, double>("SUELDO", 1500);
23: datos[4] = new KeyValuePair<string, double>("PROPINA_INFORMATICO", 4000);
24:
25:
26: Caja caja = new Caja();
27:
28: // Bucle por los valores importados
29: foreach (KeyValuePair<string,double> kpv in datos)
30: {
31: // Se obtiene el equivalente proveedor->interno
32: string keyDb = tabla[kpv.Key];
33: // Se añade el valor a la clase Caja
34: caja.AddGasto(keyDb, kpv.Value);
35: }
36: Console.WriteLine(caja.ToString());
37: Console.ReadKey();
38: }
39: }