void it_AlEncontrarColumna(ref Armador arm, Columna c, PropertyInfo pi, object val) { Columnas ac = new Columnas(c.Titulo, c.Visible); ac.Nombre = pi.Name; ac.Valores = c.Valores; ac.Formato = Formato.GetFormat(c.Formato); arm.AgregarColumna(ac); }
void it_AlEncontrarRelacion(ref Armador arm, Relacion r, PropertyInfo pi, object val) { Relacionado rc = new Relacionado { CampoId = r.CampoId, CampoSecundario = r.CampoSecundario, Destino = r.Destino, Where = r.Where, Nombre = pi.Name, PermitirNull = r.PermitirNull }; arm.AgregarRelacion(rc); }
void Class_AlEncontrarIdentificador(ref Armador arm, Identificador i, PropertyInfo pi, object val) { Atributos at; if (val != null) { at = new Atributos(i.Nombre, pi.GetValue(arm.InstanciaAsociada, null), pi, val); } else { at = new Atributos(i.Nombre, null, pi); } at.Atributo = pi.Name; at.Autogenerado = i.Autogenerado; at.SoloLectura = !i.Modificable; arm.AgregarIdentificador(at); }
public Armador CreateFromClass(Type t) { Armador arm = new Armador(t); arm.Consultar = this.Consultar; PropertyIterator it = new PropertyIterator(t); it.AlEncontrarAtributo += new PropertyIterator.Void_Atributo(Class_AlEncontrarAtributo); it.AlEncontrarIdentificador += new PropertyIterator.Void_Identificador(Class_AlEncontrarIdentificador); it.AlEncontrarColumna += new PropertyIterator.Void_Columna(it_AlEncontrarColumna); it.AlEncontrarRelacion += new PropertyIterator.Void_Relacion(it_AlEncontrarRelacion); it.Process(ref arm); arm.AsociarColumnas(); arm.AsociarRelaciones(); return arm; }
public static SqlHelper Generar(Armador arm, SqlValor[] valores) { SqlHelper sql = new SqlHelper(arm.Tipo, valores); sql.Nombre = arm.Nombre; foreach (Atributos a in arm.Atributos) { sql.Agregar(a); } foreach (Atributos a in arm.Identificadores) { sql.Identificadores.Add(a); } sql.ProcesarAtributos(); return sql; }
void Class_AlEncontrarAtributo(ref Armador arm, Atributo a, PropertyInfo pi, object val) { Atributos at; if (val != null) { at = new Atributos(a.Nombre, pi.GetValue(arm.InstanciaAsociada, null), pi, val); } else { at = new Atributos(a.Nombre, null, pi); } at.Atributo = pi.Name; at.Autogenerado = a.Autogenerado; at.SoloLectura = !a.Modificable; at.EsNumerico = a.EsNumerico; at.EsMail = a.EsMail; at.EsCuit = a.EsCuit; at.EsImporte = a.EsImporte; at.EsPorcentaje = a.EsPorcentaje; at.EsDni = a.EsDni; at.EsLetra = a.EsLetra; arm.Agregar(at); }
private void CallEventRelacion(ref Armador arm, Entidades.Relacion r, PropertyInfo pi, object val) { if (this.AlEncontrarRelacion != null) this.AlEncontrarRelacion(ref arm, r, pi, val); }
protected void Process(ref Armador arm, Type tipo) { //Recorre los atributos declarados sobre la clase foreach (object classAtri in tipo.GetCustomAttributes(false)) { if (classAtri.GetType().Equals(typeof(Heredar))) { this.Process(ref arm, ((Heredar)classAtri).Padre); } } bool atributo; // Bugfix Columna-Atributo //Recorre las properties del objeto foreach (PropertyInfo p in tipo.GetProperties()) { atributo = false; // Bugfix //Si tiene atributos personalizados... //if (p.GetCustomAttributes(true).Length > 0) //{ //Se recorren los atributos personalizados... foreach (object atri in p.GetCustomAttributes(true)) { //Si se debe ignorar el atributo, fin. if (atri.GetType().Equals(typeof(IgnorarAtributo))) { atributo = true; break; } //Si el atributo es identificador, se agrega como identificador. else if (atri.GetType().Equals(typeof(Identificador))) { Identificador i = (Identificador)atri; if (i.Nombre.Equals("")) { i.Nombre = p.Name; } atributo = true; this.CallEventIdentificador(ref arm, i, p, o); } //Si el atributo es atributo, se agrega como atributo. else if (atri.GetType().Equals(typeof(Atributo))) { Atributo at = (Atributo)atri; if (at.Nombre.Equals("")) { at.Nombre = p.Name; } atributo = true; this.CallEventAtributo(ref arm, at, p, o); } else if (atri.GetType().Equals(typeof(Entidades.Columna))) { Entidades.Columna c = (Entidades.Columna)atri; if (c.Titulo.Equals("")) { c.Titulo = p.Name; } this.CallEventColumna(ref arm, c, p, o); } else if (atri.GetType().Equals(typeof(Entidades.Relacion))) { Entidades.Relacion r = (Entidades.Relacion)atri; this.CallEventRelacion(ref arm, r, p, o); } } if (!atributo) { this.CallEventAtributo(ref arm, new Atributo(p.Name, false), p, o); } //} //else //Si no tiene atributos personalizados, se toma como que fuera un atributo. //{ // this.CallEventAtributo(ref arm, new Atributo(p.Name, false), p, o); //} } }
private void CallEventIdentificador(ref Armador arm, Identificador i, PropertyInfo pi, object val) { if (this.AlEncontrarIdentificador != null) this.AlEncontrarIdentificador(ref arm, i, pi, val); }
private void CallEventColumna(ref Armador arm, Entidades.Columna a, PropertyInfo pi, object val) { if (this.AlEncontrarColumna != null) this.AlEncontrarColumna(ref arm, a, pi, val); }
private void CallEventAtributo(ref Armador arm, Atributo a, PropertyInfo pi, object val) { if (this.AlEncontrarAtributo != null) this.AlEncontrarAtributo(ref arm, a, pi, val); }
public void Process(ref Armador arm) { this.Process(ref arm, this.t); }
public Storer(Type t) { this.t = t; this.af.Consultar = Datos.Consultar; this.armador = af.CreateFromClass(t); }