Westwind.Utilities.Expando.SetProperty C# (CSharp) Method

SetProperty() protected method

Reflection helper method to set a property value
protected SetProperty ( object instance, string name, object value ) : bool
instance object
name string
value object
return bool
        protected bool SetProperty(object instance, string name, object value)
        {
            if (instance == null)
                instance = this;

            var miArray = InstanceType.GetMember(name, BindingFlags.Public | BindingFlags.SetProperty | BindingFlags.Instance);
            if (miArray != null && miArray.Length > 0)
            {
                var mi = miArray[0];
                if (mi.MemberType == MemberTypes.Property)
                {
                    ((PropertyInfo)mi).SetValue(Instance, value, null);
                    return true;
                }
            }
            return false;
        }