Stetic.TypedPropertyDescriptor.GetValue C# (CSharp) Method

GetValue() public method

public GetValue ( object obj ) : object
obj object
return object
        public override object GetValue(object obj)
        {
            try {
                if (isWrapperProperty)
                    obj = ObjectWrapper.Lookup (obj);
                if (memberInfo != null)
                    obj = memberInfo.GetValue (obj, null);
                return propertyInfo.GetValue (obj, null);
            } catch (Exception ex) {
                throw new InvalidOperationException ("Could not get value for property " + klass.Name + "." + Name + " from object '" + obj + "'", ex);
            }
        }

Usage Example

        internal void LoadDefaultValues()
        {
            // This is a hack because there is no managed way of getting
            // the default value of a GObject property.
            // This method creates an dummy instance of this class and
            // gets the values for their properties. Those values are
            // considered the default

            if (defaultValuesLoaded)
            {
                return;
            }
            defaultValuesLoaded = true;

            object ob = NewInstance(null, false);

            foreach (ItemGroup group in ItemGroups)
            {
                foreach (ItemDescriptor item in group)
                {
                    TypedPropertyDescriptor prop = item as TypedPropertyDescriptor;
                    if (prop == null)
                    {
                        continue;
                    }

                    if (!prop.HasDefault)
                    {
                        prop.SetDefault(null);
                    }
                    else
                    {
                        object val = prop.GetValue(ob);
                        prop.SetDefault(val);
                    }
                }
            }
            ObjectWrapper ww = ObjectWrapper.Lookup(ob);

            ww.Dispose();
        }
All Usage Examples Of Stetic.TypedPropertyDescriptor::GetValue