private PropertyInfo ObtenerElPropertyDelObjetoSiExiste() { IdConPunto referencia = (IdConPunto)lValue; string id = referencia.instancia(); Objeto instancia = tablaDeSimbolos.Valor(id); string nombreDeLaPropiedad = referencia.Propiedad(); string propertyUnsensitivo = nombreDeLaPropiedad.ToUpper(); PropertyInfo propertyEncontrado = null; foreach (PropertyInfo property in instancia.GetType().GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)) { string propertyName = property.Name.ToUpper(); if (propertyName == propertyUnsensitivo && property.SetMethod != null) { ParameterInfo[] variables = property.SetMethod.GetParameters(); variables = QuitarleValueDelSetProperty(variables); bool tienenLaMismaCantidadDeArgumentos = (variables.Length == 0 && referencia.Argumentos() == null) || (variables.Length == referencia.Argumentos().Length); if (tienenLaMismaCantidadDeArgumentos) { bool sonValidasLasFirmas = referencia.ValidarLaIntegridadDeLosArgumentosDelMetodo(variables); if (sonValidasLasFirmas) { propertyEncontrado = property; break; } } } } return(propertyEncontrado); }
public override void Ejecutar() { if (lValue is IdConPunto) { IdConPunto referencia = (IdConPunto)lValue; string instancia = referencia.instancia(); if (!tablaDeSimbolos.ExisteLaVariable(instancia)) { throw new LanguageException(string.Format("No se ha definido la variable {0}. Verifique el nombre", instancia)); } Objeto objeto = tablaDeSimbolos.Valor(instancia); Objeto valorDeLaExpresionDerecha = rValue.ejecutar(); FieldInfo fieldInfo = ObtenerElFieldDelObjetoSiExiste(); if (fieldInfo != null) { fieldInfo.SetValue(objeto, ImplicitCast(UnBoxing(valorDeLaExpresionDerecha), fieldInfo.FieldType)); return; } PropertyInfo propertyInfo = ObtenerElPropertyDelObjetoSiExiste(); if (propertyInfo != null) { propertyInfo.SetValue(objeto, ImplicitCast(UnBoxing(valorDeLaExpresionDerecha), propertyInfo.PropertyType)); return; } else { objeto.setAtributo(referencia.Propiedad(), valorDeLaExpresionDerecha); } } else if (lValue is PuntoConPunto) { } else { string nuevaVariable = ((Id)lValue).Valor; Objeto valorDeLaExpresionDerecha = rValue.ejecutar(); tablaDeSimbolos.GuardarVariable(nuevaVariable, valorDeLaExpresionDerecha); } }
private FieldInfo ObtenerElFieldDelObjetoSiExiste() { IdConPunto referencia = (IdConPunto)lValue; string id = referencia.instancia(); Objeto instancia = tablaDeSimbolos.Valor(id); string nombreDelField = referencia.Propiedad(); FieldInfo fieldEncontrado = null; string fieldUnsensitivo = nombreDelField.ToUpper(); foreach (FieldInfo field in instancia.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance)) { if (field.IsPublic || field.IsAssembly) { string fieldName = field.Name.ToUpper(); if (fieldName == fieldUnsensitivo) { fieldEncontrado = field; break; } } } return(fieldEncontrado); }