예제 #1
0
        private bool TrySetProperty(Context context, IValue value, string attrName)
        {
            PropertyInfo property = instance.GetType().GetProperty(attrName, bindingFlags);

            if (property != null)
            {
                property.SetValue(instance, value.ConvertTo(context, property.PropertyType), null);
            }
            return(property != null);
        }
예제 #2
0
        private bool TrySetField(Context context, IValue value, string attrName)
        {
            FieldInfo field = instance.GetType().GetField(attrName, bindingFlags);

            if (field != null)
            {
                field.SetValue(instance, value.ConvertTo(context, field.FieldType));
            }
            return(field != null);
        }