System.ComponentModel.ReflectPropertyDescriptor.GetValue C# (CSharp) Method

GetValue() public method

Retrieves the current value of the property on component, invoking the getXXX method. An exception in the getXXX method will pass through.
public GetValue ( object component ) : object
component object
return object
        public override object GetValue(object component)
        {
            Debug.WriteLine($"[{Name}]: GetValue({component?.GetType().Name ?? "(null)"})");

            if (IsExtender)
            {
                Debug.WriteLine("[" + Name + "]:   ---> returning: null");
                return null;
            }

            Debug.Assert(component != null, "GetValue must be given a component");

            if (component != null)
            {
                component = GetInvocationTarget(_componentClass, component);


                try
                {
                    return GetMethodValue.Invoke(component, null);
                }
                catch (Exception t)
                {
                    string name = null;
                    IComponent comp = component as IComponent;
                    if (comp != null)
                    {
                        ISite site = comp.Site;
                        if (site != null && site.Name != null)
                        {
                            name = site.Name;
                        }
                    }

                    if (name == null)
                    {
                        name = component.GetType().FullName;
                    }

                    if (t is TargetInvocationException)
                    {
                        t = t.InnerException;
                    }

                    string message = t.Message;
                    if (message == null)
                    {
                        message = t.GetType().Name;
                    }

                    throw new TargetInvocationException(string.Format(SR.ErrorPropertyAccessorException, Name, name, message), t);
                }
            }
            Debug.WriteLine("[" + Name + "]:   ---> returning: null");
            return null;
        }