示例#1
0
        public IMemberAccessor GetProperty(string name)
        {
            name.ThrowIfNullOrEmpty();

            IMemberAccessor accessor;

            if (_propertyCache.Value.TryGetValue(name, out accessor))
            {
                return(accessor);
            }

            var propertyInfo = Type.GetProperty(name);
            var value        = PropertyAccessor.Create(propertyInfo);

            _propertyCache.Value.Add(name, value);

            return(value);
        }
示例#2
0
        public IMemberAccessor GetProperty <T>(Expression <Func <T, object> > expression)
        {
            expression.ThrowIfNull();

            var propertyInfo = expression.GetPropertyAccess();

            IMemberAccessor accessor;

            if (_propertyCache.Value.TryGetValue(propertyInfo.Name, out accessor))
            {
                return(accessor);
            }

            var value = PropertyAccessor.Create(propertyInfo);

            _propertyCache.Value.Add(propertyInfo.Name, value);

            return(value);
        }