internal void NotificarRemover(IPropiedad propiedad, IObjetoDatos item, int indice) { Notificar(new NotificacionColeccion(ObjetoDatos, propiedad) { Accion = Accion.Remover, Item = item, Indice = indice }); }
public virtual void Leer(IObjetoDatos od) { if (od == null) { return; } int id = LeerId(); if (!_oid.Existe(id)) { _oid.Agregar(od, id); } Tipo = od.Tipo; IPropiedad propiedad = Leer(); while (propiedad != null) { //System.Diagnostics.Debug.WriteLine(string.Format("[id={0}] - {1}", id, propiedad.Nombre)); Leer(od, propiedad); propiedad = Leer(); } }
public void EvaluarObjetoDatosComplejoRemoverUnItem() { IObjetoDatos od = Helper.Crear(_tipox); Helper.Construir(od, 1, 3); od.RemoverObjetoDatos("ReferenciaObjetoDatosItem", od.ObtenerColeccion("ReferenciaObjetoDatosItem")[0]); Assert.AreEqual(od.ObtenerColeccion("ReferenciaObjetoDatosItem").Longitud, 2); }
public void Agregar(IObjetoDatos od, int id) { if (_ids.ContainsKey(id)) { return; } _ids.Add(id, od); }
public static string ObtenerString(IObjetoDatos od, string ruta) { IObjetoDatos referencia; IPropiedad propiedad; Resolver(od, ruta, out referencia, out propiedad); return(referencia != null && propiedad != null ? referencia.ObtenerString(propiedad) : default(string)); }
public MetodoEscrituraTipo(IModeloEscritura modelo, IEscritor escritor, IMetodoEscritura metodoEscritura, IObjetoDatos od, int refid) : base(modelo, escritor) { _od = od; _tipo = od.Tipo; _refid = refid; _metodo = Metodo.Tipo; _metodoescritura = metodoEscritura; }
public EscritorObjetoDatos(IEscritor escritor, IObjetoDatos od) { _escritor = escritor; _od = od; _propiedades = from propiedad in _od.Tipo.Propiedades where propiedad.Tipo.EsTipoDeDato && _od.Establecido(propiedad) select propiedad; }
internal ModeloLectura(ILector lector, IObjetoDatos od) { _lector = lector; _od = od; _stack = new Identidad(); _asociaciones = new List <IMetodoAsociacion>(); ConstruirTipos(); }
private void ConstruirNodos(Root root) { IObjetoDatos od = root.Objeto.ObjetoDatos; foreach (IPropiedad propiedad in od.Tipo.Propiedades) { CrearPropiedad(root, propiedad); } }
public ModeloEscritura(IEscritor escritor, IObjetoDatos od) { _escritor = escritor; _stack = new Identidad(); _od = new List <IObjetoDatos>() { od }; }
/// <summary> /// Obtiene el identificador a partir del objeto de datos. /// </summary> public int Obtener(IObjetoDatos od) { if (!_identidades.Contains(od)) { _identidades.Add(od); } return(_identidades.IndexOf(od)); }
public void DeshacerCambiosEnObjetoDatos() { // arrange Log controlador = new Log(); //FabricaHistorial fabrica = new FabricaHistorial(); IFabrica fabrica = new FabricaHistorial(controlador); IObjetoDatos od = fabrica.Crear(HelperTipo.ObtenerTipo()); // act bool valorBoolean = od.ObtenerBoolean(0); byte valorByte = od.ObtenerByte(1); char valorChar = od.ObtenerChar(2); DateTime valorDateTime = od.ObtenerDateTime(3); var valorDecimal = od.ObtenerDecimal(4); var valorDouble = od.ObtenerDouble(5); var valorFloat = od.ObtenerFloat(6); var valorInteger = od.ObtenerInteger(7); var valorLong = od.ObtenerLong(8); var valorSByte = od.ObtenerSByte(9); var valorShort = od.ObtenerShort(10); var valorString = od.ObtenerString(11); var valorUInteger = od.ObtenerUInteger(12); var valorULong = od.ObtenerULong(13); var valorUShort = od.ObtenerUShort(14); // establecer valores //EstablecerValoresPorIndice(od); Helper.Construir(od); // deshacer cambios controlador.Deshacer(); //// establecer valores ////EstablecerValoresPorTipoPorIndice(od); //Helper.Construir(od); //// deshacer cambios //controlador.Deshacer(); // assert Assert.AreEqual(od.ObtenerBoolean(0), valorBoolean, $"Se esperaba {valorBoolean}"); Assert.AreEqual(od.ObtenerByte(1), valorByte, $"Se esperaba {valorByte}"); Assert.AreEqual(od.ObtenerChar(2), valorChar, $"Se esperaba {valorChar}"); Assert.AreEqual(od.ObtenerDateTime(3), valorDateTime, $"Se esperaba {valorDateTime}"); Assert.AreEqual(od.ObtenerDecimal(4), valorDecimal, $"Se esperaba {valorDecimal}"); Assert.AreEqual(od.ObtenerDouble(5), valorDouble, $"Se esperaba {valorDouble}"); Assert.AreEqual(od.ObtenerFloat(6), valorFloat, $"Se esperaba {valorFloat}"); Assert.AreEqual(od.ObtenerInteger(7), valorInteger, $"Se esperaba {valorInteger}"); Assert.AreEqual(od.ObtenerLong(8), valorInteger, $"Se esperaba {valorInteger}"); Assert.AreEqual(od.ObtenerSByte(9), valorSByte, $"Se esperaba {valorSByte}"); Assert.AreEqual(od.ObtenerShort(10), valorShort, $"Se esperaba {valorShort}"); Assert.AreEqual(od.ObtenerString(11), valorString, $"Se esperaba {valorString ?? ""}"); Assert.AreEqual(od.ObtenerUInteger(12), valorUInteger, $"Se esperaba {valorUInteger}"); Assert.AreEqual(od.ObtenerULong(13), valorULong, $"Se esperaba {valorULong}"); Assert.AreEqual(od.ObtenerUShort(14), valorUShort, $"Se esperaba {valorUShort}"); }
public void EvaluarObjetoDatosPathObtenerPorTipo() { IObjetoDatos od = Helper.Crear(_tipox); Helper.Construir(od, 2, 0); string ruta = "ReferenciaObjetoDatos"; bool valorBoolean = true; byte valorByte = 125; char valorChar = 'D'; DateTime valorDateTime = DateTime.Now; decimal valorDecimal = new decimal(15896658.100245); double valorDouble = 448995.55698; float valorFloat = (float)56625.55; int valorInteger = -102458; long valorLong = -89665522321; sbyte valorSByte = 89; short valorShort = 5444; string valorString = "cadena de texto"; uint valorUInteger = 89955212; ulong valorULong = 788554421056; ushort valorUShort = 9035; od.EstablecerBoolean($"{ruta}/atributoBoolean", valorBoolean); od.EstablecerByte($"{ruta}/atributoByte", valorByte); od.EstablecerChar($"{ruta}/atributoChar", valorChar); od.EstablecerDateTime($"{ruta}/atributoDateTime", valorDateTime); od.EstablecerDecimal($"{ruta}/atributoDecimal", valorDecimal); od.EstablecerDouble($"{ruta}/atributoDouble", valorDouble); od.EstablecerFloat($"{ruta}/atributoFloat", valorFloat); od.EstablecerInteger($"{ruta}/atributoInteger", valorInteger); od.EstablecerLong($"{ruta}/atributoLong", valorLong); od.EstablecerSByte($"{ruta}/atributoSByte", valorSByte); od.EstablecerShort($"{ruta}/atributoShort", valorShort); od.EstablecerString($"{ruta}/atributoString", valorString); od.EstablecerUInteger($"{ruta}/atributoUInteger", valorUInteger); od.EstablecerULong($"{ruta}/atributoULong", valorULong); od.EstablecerUShort($"{ruta}/atributoUShort", valorUShort); Assert.AreEqual(valorBoolean, od.ObtenerBoolean($"{ruta}/atributoBoolean")); Assert.AreEqual(valorByte, od.ObtenerByte($"{ruta}/atributoByte")); Assert.AreEqual(valorChar, od.ObtenerChar($"{ruta}/atributoChar")); Assert.AreEqual(valorDateTime, od.ObtenerDateTime($"{ruta}/atributoDateTime")); Assert.AreEqual(valorDecimal, od.ObtenerDecimal($"{ruta}/atributoDecimal")); Assert.AreEqual(valorDouble, od.ObtenerDouble($"{ruta}/atributoDouble")); Assert.AreEqual(valorFloat, od.ObtenerFloat($"{ruta}/atributoFloat")); Assert.AreEqual(valorInteger, od.ObtenerInteger($"{ruta}/atributoInteger")); Assert.AreEqual(valorLong, od.ObtenerLong($"{ruta}/atributoLong")); Assert.AreEqual(valorSByte, od.ObtenerSByte($"{ruta}/atributoSByte")); Assert.AreEqual(valorShort, od.ObtenerShort($"{ruta}/atributoShort")); Assert.AreEqual(valorString, od.ObtenerString($"{ruta}/atributoString")); Assert.AreEqual(valorUInteger, od.ObtenerUInteger($"{ruta}/atributoUInteger")); Assert.AreEqual(valorULong, od.ObtenerULong($"{ruta}/atributoULong")); Assert.AreEqual(valorUShort, od.ObtenerUShort($"{ruta}/atributoUShort")); }
void Leer(IObjetoDatos od, IPropiedad propiedad) { if (propiedad.Tipo.EsTipoDeDato) { LeerAtributo(od, propiedad); } else { LeerReferencia(od, propiedad); } }
protected void EstablecerObjetoDatos(string ruta, IObjetoDatos valor) { if (helper.ComprobarRuta(ref ruta)) { helper.EstablecerObjetoDatos(this, ruta, valor); } else { _impl.EstablecerObjetoDatos(Tipo.ObtenerPropiedad(ruta), valor); } }
public static void ConstruirObjetoDatos(IObjetoDatos od) { if (od.Tipo == _tipo) { Test.Helper.Construir(od); } else if (od.Tipo == _tipox) { Test.Helper.Construir(od, 2, 5); } }
private IMetodoEscritura Crear(IObjetoDatos od) { IMetodoEscritura metodo; IMetodoEscritura metodood; int refid = _stack.Obtener(od); metodood = new MetodoEscrituraObjetoDatos(this, _escritor, od, refid); metodo = new MetodoEscrituraTipo(this, _escritor, metodood, od, refid); return(metodo); }
private int ResolverIndice(IPropiedad propiedad, IObjetoDatos item) { int indice = 0; if (propiedad.Cardinalidad >= Cardinalidad.Muchos) { indice = _impl.ObtenerColeccion(propiedad).Indice(item); } return(indice); }
public MetodoEscrituraObjetoDatos(IModeloEscritura modelo, IEscritor escritor, IObjetoDatos od, int refid) : base(modelo, escritor) { EscritorObjetoDatos escritorod = new EscritorObjetoDatos(escritor, od); _longitud = escritorod.Longitud; _escritorod = escritorod; _refid = refid; _od = od; _metodo = Metodo.ObjetoDatos; }
private void ActualizarColeccion(IObjetoDatos od, IPropiedad propiedad, Accion accion, IObjetoDatos item, int indice) { if (accion == Accion.Agregar) { CrearObservador(item, ObjetoDatos.CrearObjetoDatos(propiedad)); } else if (accion == Accion.Remover) { ObjetoDatos.RemoverObjetoDatos(propiedad, ObjetoDatos.ObtenerColeccion(propiedad)[indice]); } }
private void ActualizarPropiedad(IObjetoDatos od, IPropiedad propiedad) { if (propiedad.Tipo.EsTipoDeDato || propiedad.Asociacion == Asociacion.Agregacion || od.ObtenerObjetoDatos(propiedad) == null) { ObjetoDatos.Establecer(propiedad, od.Obtener(propiedad)); } else if (propiedad.Asociacion == Asociacion.Composicion) { CrearObservador(od.ObtenerObjetoDatos(propiedad), ObjetoDatos.CrearObjetoDatos(propiedad)); } }
protected void RemoverObjetoDatos(string ruta, IObjetoDatos item) { if (helper.ComprobarRuta(ref ruta)) { helper.RemoverObjetoDatos(this, ruta, item); } else { _impl.RemoverObjetoDatos(Tipo[ruta], item); } }
public ObjetoMap Obtener(IObjetoDatos od) { if (!_maps.ContainsKey(od)) { return(Crear(od)); } else { return(_maps[od]); } }
private static void ConstruirColeccion(IObjetoDatos od, IPropiedad propiedad, int niveles, int items) { if (niveles == 0) { return; } for (int i = 1; i <= items; i++) { Construir(od.CrearObjetoDatos(propiedad), (niveles - 1), items); } }
public Diagrama Crear(IObjetoDatos od) { _heap = new Heap(); _diag = new Diagrama(); _agre = new Dictionary <IObjetoDatos, NodoObjeto>(); CrearRoot(od); ConstruirNodos(_diag.Root); ResolverNodos(); return(_diag); }
void CrearObservador(IObjetoDatos od1, IObjetoDatos od2) { if (od1 == null || od2 == null) { return; } Observable observable = ((ObjetoBase)od1).Observable(); Observador observador = new Observador(od2); observable.Agregar(observador); }
public void EvaluarEstablecerPorIndice() { IObjetoDatos od = Fabrica.Instancia.Crear(_tipo); Random rnd = new Random(); bool valorBoolean = true; byte valorByte = byte.MaxValue; char valorChar = char.MaxValue; DateTime valorDateTime = DateTime.MaxValue; decimal valorDecimal = decimal.MaxValue; double valorDouble = double.MaxValue; float valorFloat = float.MaxValue; int valorInteger = int.MaxValue; long valorLong = long.MaxValue; sbyte valorSByte = sbyte.MaxValue; short valorShort = short.MaxValue; string valorString = "abcdefghijklmnoprstuvwxyz"; uint valorUInteger = uint.MaxValue; ulong valorULong = ulong.MaxValue; ushort valorUShort = ushort.MaxValue; od.Establecer(0, valorBoolean); od.Establecer(1, valorByte); od.Establecer(2, valorChar); od.Establecer(3, valorDateTime); od.Establecer(4, valorDecimal); od.Establecer(5, valorDouble); od.Establecer(6, valorFloat); od.Establecer(7, valorInteger); od.Establecer(8, valorLong); od.Establecer(9, valorSByte); od.Establecer(10, valorShort); od.Establecer(11, valorString); od.Establecer(12, valorUInteger); od.Establecer(13, valorULong); od.Establecer(14, valorUShort); Assert.AreEqual(od.Obtener(0), valorBoolean); Assert.AreEqual(od.Obtener(1), valorByte); Assert.AreEqual(od.Obtener(2), valorChar); Assert.AreEqual(od.Obtener(3), valorDateTime); Assert.AreEqual(od.Obtener(4), valorDecimal); Assert.AreEqual(od.Obtener(5), valorDouble); Assert.AreEqual(od.Obtener(6), valorFloat); Assert.AreEqual(od.Obtener(7), valorInteger); Assert.AreEqual(od.Obtener(8), valorLong); Assert.AreEqual(od.Obtener(9), valorSByte); Assert.AreEqual(od.Obtener(10), valorShort); Assert.AreEqual(od.Obtener(11), valorString); Assert.AreEqual(od.Obtener(12), valorUInteger); Assert.AreEqual(od.Obtener(13), valorULong); Assert.AreEqual(od.Obtener(14), valorUShort); }
public static void EstablecerUShort(IObjetoDatos od, string ruta, ushort valor) { IObjetoDatos referencia; IPropiedad propiedad; Resolver(od, ruta, out referencia, out propiedad); if (referencia != null && propiedad != null) { referencia.EstablecerUShort(propiedad, valor); } }
internal static void RemoverObjetoDatos(IObjetoDatos od, string ruta, IObjetoDatos item) { IObjetoDatos referencia; IPropiedad propiedad; Resolver(od, ruta, out referencia, out propiedad); if (referencia != null && propiedad != null) { referencia.RemoverObjetoDatos(propiedad, item); } }
public void EvaluarEstablecerPorNombre() { IObjetoDatos od = Fabrica.Instancia.Crear(_tipo); Random rnd = new Random(); bool valorBoolean = true; byte valorByte = byte.MaxValue; char valorChar = char.MaxValue; DateTime valorDateTime = DateTime.MaxValue; decimal valorDecimal = decimal.MaxValue; double valorDouble = double.MaxValue; float valorFloat = float.MaxValue; int valorInteger = int.MaxValue; long valorLong = long.MaxValue; sbyte valorSByte = sbyte.MaxValue; short valorShort = short.MaxValue; string valorString = "abcdefghijklmnoprstuvwxyz"; uint valorUInteger = uint.MaxValue; ulong valorULong = ulong.MaxValue; ushort valorUShort = ushort.MaxValue; od.Establecer("atributoBoolean", valorBoolean); od.Establecer("atributoByte", valorByte); od.Establecer("atributoChar", valorChar); od.Establecer("atributoDateTime", valorDateTime); od.Establecer("atributoDecimal", valorDecimal); od.Establecer("atributoDouble", valorDouble); od.Establecer("atributoFloat", valorFloat); od.Establecer("atributoInteger", valorInteger); od.Establecer("atributoLong", valorLong); od.Establecer("atributoSByte", valorSByte); od.Establecer("atributoShort", valorShort); od.Establecer("atributoString", valorString); od.Establecer("atributoUInteger", valorUInteger); od.Establecer("atributoULong", valorULong); od.Establecer("atributoUShort", valorUShort); Assert.AreEqual(od.Obtener("atributoBoolean"), valorBoolean); Assert.AreEqual(od.Obtener("atributoByte"), valorByte); Assert.AreEqual(od.Obtener("atributoChar"), valorChar); Assert.AreEqual(od.Obtener("atributoDateTime"), valorDateTime); Assert.AreEqual(od.Obtener("atributoDecimal"), valorDecimal); Assert.AreEqual(od.Obtener("atributoDouble"), valorDouble); Assert.AreEqual(od.Obtener("atributoFloat"), valorFloat); Assert.AreEqual(od.Obtener("atributoInteger"), valorInteger); Assert.AreEqual(od.Obtener("atributoLong"), valorLong); Assert.AreEqual(od.Obtener("atributoSByte"), valorSByte); Assert.AreEqual(od.Obtener("atributoShort"), valorShort); Assert.AreEqual(od.Obtener("atributoString"), valorString); Assert.AreEqual(od.Obtener("atributoUInteger"), valorUInteger); Assert.AreEqual(od.Obtener("atributoULong"), valorULong); Assert.AreEqual(od.Obtener("atributoUShort"), valorUShort); }