Beispiel #1
0
        private static bool TryGetCachedProperty(
            Type type,
            string propertyName,
            bool eagerCached,
            out FastProperty fastProperty)
        {
            fastProperty = null;
            IDictionary <string, FastProperty> allProperties;

            if (eagerCached)
            {
                allProperties = (IDictionary <string, FastProperty>)GetProperties(type);
                allProperties.TryGetValue(propertyName, out fastProperty);
            }

            if (fastProperty == null && _propertiesCache.TryGetValue(type, out allProperties))
            {
                allProperties.TryGetValue(propertyName, out fastProperty);
            }

            return(fastProperty != null);
        }
Beispiel #2
0
        private IDictionary <string, FastProperty> GetInstanceProperties()
        {
            if (_instance == null)
            {
                return(EmptyProps);
            }

            if (_instanceProps == null)
            {
                var props = FastProperty.GetProperties(_instance) as IDictionary <string, FastProperty>;

                if (_optMembers != null)
                {
                    props = props
                            .Where(x => _optMethod == MemberOptMethod.Allow ? _optMembers.Contains(x.Key) : !_optMembers.Contains(x.Key))
                            .ToDictionary(x => x.Key, x => x.Value);
                }

                _instanceProps = props;
            }

            return(_instanceProps);
        }