Exemplo n.º 1
0
                /// <summary>
                /// Given an object fetch the property that this PropertySpec represents.
                /// </summary>
                public object Fetch(object obj)
                {
                    Type          objType = obj.GetType();
                    PropertyFetch fetch   = _fetchForExpectedType;

                    if (fetch == null || fetch.Type != objType)
                    {
                        _fetchForExpectedType = fetch = PropertyFetch.FetcherForProperty(
                            objType, objType.GetTypeInfo().GetDeclaredProperty(_propertyName));
                    }
                    return(fetch.Fetch(obj));
                }
Exemplo n.º 2
0
        public object Fetch(object obj)
        {
            PropertyFetch fetch   = this.innerFetcher;
            Type          objType = obj?.GetType();

            if (fetch == null || fetch.Type != objType)
            {
                this.innerFetcher = fetch = PropertyFetch.FetcherForProperty(objType, objType?.GetTypeInfo()?.GetDeclaredProperty(this.propertyName));
            }

            return(fetch?.Fetch(obj));
        }