Westwind.Utilities.Expando.GetProperty C# (CSharp) Méthode

GetProperty() protected méthode

Reflection Helper method to retrieve a property
protected GetProperty ( object instance, string name, object &result ) : bool
instance object
name string
result object
Résultat bool
        protected bool GetProperty(object instance, string name, out object result)
        {
            if (instance == null)
                instance = this;

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

            result = null;
            return false;
        }