示例#1
0
        private IEnumerable <IMemberAccessor> GetFields(BindingFlags bindings)
        {
            var fields = Type.GetFields(bindings);

            foreach (var fieldInfo in fields)
            {
                yield return(_fieldCache.Value.GetOrAdd(
                                 fieldInfo.Name,
                                 () => FieldAccessor.Create(fieldInfo)));
            }
        }
示例#2
0
        private IMemberAccessor GetField(string name, BindingFlags bindings)
        {
            name.ThrowIfNullOrEmpty();

            IMemberAccessor accessor;

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

            var fieldInfo = Type.GetField(name, bindings);
            var value     = FieldAccessor.Create(fieldInfo);

            _fieldCache.Value.Add(name, value);

            return(value);
        }