コード例 #1
0
        public VirtualPropertyInfo(
            string name,
            Type propertyType,
            Func <object, object> getter,
            Action <object, object> setter,
            IEnumerable <Attribute> propertyAttributes,
            IEnumerable <Attribute> getterAttributes,
            IEnumerable <Attribute> setterAttributes,
            CustomReflectionContext context)
            : base(propertyType, name, context)
        {
            if (getter == null && setter == null)
            {
                throw new ArgumentException(SR.ArgumentNull_GetterOrSetterMustBeSpecified);
            }

            CustomType rcType = propertyType as CustomType;

            if (rcType == null || rcType.ReflectionContext != context)
            {
                throw new ArgumentException(SR.Argument_PropertyTypeFromDifferentContext);
            }

            if (getter != null)
            {
                _getter = new PropertyGetter(this, getter, getterAttributes);
            }

            if (setter != null)
            {
                _setter = new PropertySetter(this, setter, setterAttributes);
            }

            _attributes = propertyAttributes ?? CollectionServices.Empty <Attribute>();
        }
コード例 #2
0
        public static object[] GetCustomAttributes(CustomReflectionContext context, CustomEventInfo evnt, Type attributeFilterType, bool inherit)
        {
            EventInfo            provider   = evnt.UnderlyingEvent;
            IEnumerable <object> attributes = GetFilteredAttributes(context, provider, attributeFilterType);

            return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
        }
コード例 #3
0
        public static object[] GetCustomAttributes(CustomReflectionContext context, CustomParameterInfo parameter, Type attributeFilterType, bool inherit)
        {
            ParameterInfo        provider   = parameter.UnderlyingParameter;
            IEnumerable <object> attributes = GetFilteredAttributes(context, provider, attributeFilterType);

            return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
        }
コード例 #4
0
ファイル: VirtualPropertyBase.cs プロジェクト: zqb971/mef
        protected VirtualPropertyBase(Type propertyType, string name, CustomReflectionContext context)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            if (name.Length == 0)
            {
                throw new ArgumentException("name");
            }

            if (propertyType == null)
            {
                throw new ArgumentNullException("propertyType");
            }
            Contract.EndContractBlock();

            Contract.Assert(propertyType != null);
            Contract.Assert(context != null);

            _propertyType = propertyType;
            _name         = name;
            _context      = context;
        }
コード例 #5
0
        public static object[] GetCustomAttributes(CustomReflectionContext context, CustomMethodInfo method, Type attributeFilterType, bool inherit)
        {
            IEnumerable <object> attributes = GetFilteredAttributes(context, method.UnderlyingMethod, attributeFilterType);

            if (!inherit)
            {
                return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
            }

            CustomMethodInfo baseMember = method.GetBaseDefinition() as CustomMethodInfo;

            if (baseMember == null || baseMember.Equals(method))
            {
                return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
            }

            // GetAttributeUsage is expensive and should be put off as much as possible.
            bool isSealed = attributeFilterType.IsSealed;
            bool inherited;
            bool allowMultiple;

            GetAttributeUsage(attributeFilterType, out inherited, out allowMultiple);

            if (isSealed && !inherited)
            {
                return(CollectionServices.IEnumerableToArray(attributes, attributeFilterType));
            }

            // declaredAttributes should have already been filtered by attributeFilterType
            List <object> results = new List <object>(attributes);

            do
            {
                if (isSealed && results.Count > 0 && !allowMultiple)
                {
                    break;
                }

                method = baseMember;

                IEnumerable <object> inheritedAttributes = GetFilteredAttributes(context, method.UnderlyingMethod, attributeFilterType);
                CombineCustomAttributes(results, inheritedAttributes, attributeFilterType, inherited, allowMultiple);

                baseMember = method.GetBaseDefinition() as CustomMethodInfo;
            } while (baseMember != null && !baseMember.Equals(method));

            return(CollectionServices.ConvertListToArray(results, attributeFilterType));
        }
コード例 #6
0
        protected VirtualPropertyBase(Type propertyType, string name, CustomReflectionContext context)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (name.Length == 0)
            {
                throw new ArgumentException("", nameof(name));
            }

            if (propertyType == null)
            {
                throw new ArgumentNullException(nameof(propertyType));
            }

            Debug.Assert(context != null);

            _propertyType     = propertyType;
            _name             = name;
            ReflectionContext = context;
        }
コード例 #7
0
        private static IEnumerable <object> GetFilteredAttributes(CustomReflectionContext context, ParameterInfo parameter, Type attributeFilterType)
        {
            object[] objects = parameter.GetCustomAttributes(attributeFilterType, false);

            return(context.GetCustomAttributesOnParameter(parameter, objects, attributeFilterType));
        }
コード例 #8
0
ファイル: CustomModule.cs プロジェクト: z77ma/runtime
 public CustomModule(Module template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     ReflectionContext = context;
 }
コード例 #9
0
ファイル: CustomFieldInfo.cs プロジェクト: z77ma/runtime
 public CustomFieldInfo(FieldInfo template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     ReflectionContext = context;
 }
コード例 #10
0
 public CustomConstructorInfo(ConstructorInfo template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     ReflectionContext = context;
 }
コード例 #11
0
 public CustomParameterInfo(ParameterInfo template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     ReflectionContext = context;
 }
コード例 #12
0
ファイル: CustomPropertyInfo.cs プロジェクト: z77ma/runtime
 public CustomPropertyInfo(PropertyInfo template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     ReflectionContext = context;
 }
コード例 #13
0
ファイル: CustomEventInfo.cs プロジェクト: zqb971/mef
 public CustomEventInfo(EventInfo template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     _context = context;
 }
コード例 #14
0
 public CustomType(Type template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     ReflectionContext = context;
 }
コード例 #15
0
 public CustomAssembly(Assembly template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     _context = context;
 }
コード例 #16
0
 public CustomMethodInfo(MethodInfo template, CustomReflectionContext context)
     : base(template, context.Projector)
 {
     _context = context;
 }