示例#1
0
        private ReflectParameterDescriptor(
            [NotNull] ReflectParameterDescriptorInitializationInfo initializationInfo)
            : base(
                initializationInfo.ParameterName,
                initializationInfo.ParameterType)
        {
            var members = initializationInfo.Members.ToArray();

            var attributesData = members.Last().GetCustomAttributesData();

            foreach (var a in attributesData)
            {
                if (a.AttributeType == typeof(DynamicParameterAttribute))
                {
                    this.Attributes.Add(new ParameterAttributeData(a));
                }
                else if (!Attribute.IsDefined(a.AttributeType, typeof(DynamicParameterInternalAttribute)))
                {
                    this.Attributes.Add(a);
                }
            }

            this.Members = members;

            CreateAccessors(members, out var getAccessor, out var setAccessor);

            this._getValueAccessor = getAccessor;
            this._setValueAccessor = setAccessor;
        }
示例#2
0
        internal static ReflectParameterDescriptor GetParameterDescriptor(
            [NotNull][ItemNotNull] IReadOnlyList <MemberInfo> members)
        {
            if (!_descriptorCache.TryGetValue(members, out var descriptor))
            {
                var initializationInfo = new ReflectParameterDescriptorInitializationInfo(members);
                _descriptorCache[members] = descriptor = new ReflectParameterDescriptor(initializationInfo);
            }

            return(descriptor);
        }