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>(); }
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)); }
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)); }
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; }
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)); }
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; }
private static IEnumerable <object> GetFilteredAttributes(CustomReflectionContext context, ParameterInfo parameter, Type attributeFilterType) { object[] objects = parameter.GetCustomAttributes(attributeFilterType, false); return(context.GetCustomAttributesOnParameter(parameter, objects, attributeFilterType)); }
public CustomModule(Module template, CustomReflectionContext context) : base(template, context.Projector) { ReflectionContext = context; }
public CustomFieldInfo(FieldInfo template, CustomReflectionContext context) : base(template, context.Projector) { ReflectionContext = context; }
public CustomConstructorInfo(ConstructorInfo template, CustomReflectionContext context) : base(template, context.Projector) { ReflectionContext = context; }
public CustomParameterInfo(ParameterInfo template, CustomReflectionContext context) : base(template, context.Projector) { ReflectionContext = context; }
public CustomPropertyInfo(PropertyInfo template, CustomReflectionContext context) : base(template, context.Projector) { ReflectionContext = context; }
public CustomEventInfo(EventInfo template, CustomReflectionContext context) : base(template, context.Projector) { _context = context; }
public CustomType(Type template, CustomReflectionContext context) : base(template, context.Projector) { ReflectionContext = context; }
public CustomAssembly(Assembly template, CustomReflectionContext context) : base(template, context.Projector) { _context = context; }
public CustomMethodInfo(MethodInfo template, CustomReflectionContext context) : base(template, context.Projector) { _context = context; }