AjScript.ObjectUtilities.SetValue C# (CSharp) Method

SetValue() public static method

public static SetValue ( object obj, string name, object value ) : void
obj object
name string
value object
return void
        public static void SetValue(object obj, string name, object value)
        {
            if (obj is IObject)
            {
                ((IObject)obj).SetValue(name, value);

                return;
            }

            if (obj is IContext)
            {
                ((IContext)obj).SetValue(name, value);

                return;
            }

            Type type = obj.GetType();

            type.InvokeMember(name, System.Reflection.BindingFlags.SetProperty | System.Reflection.BindingFlags.SetField | System.Reflection.BindingFlags.IgnoreCase | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, obj, new object[] { value });
        }

Usage Example

Ejemplo n.º 1
0
        private static void SetValue(DotExpression expression, object value, IContext context)
        {
            if (expression.Arguments != null)
            {
                throw new InvalidOperationException("Invalid left value");
            }

            object obj = ResolveToObject(expression.Expression, context);

            ObjectUtilities.SetValue(obj, expression.Name, value);
        }