private void CreateAppliesToFilter(Type modifierClass) { if (!typeof(InvocationHandler).IsAssignableFrom(modifierClass)) { this.appliesToFilter = new TypedModifierAppliesToFilter(); if (modifierClass.IsAbstract) { this.appliesToFilter = new AndAppliesToFilter(this.appliesToFilter, new ImplementsMethodAppliesToFilter()); } } var appliesTo = modifierClass.GetAttribute <AppliesToAttribute>(); if (appliesTo != null) { foreach (Type appliesToClass in appliesTo.AppliesToTypes) { AppliesToFilter filter; if (typeof(AppliesToFilter).IsAssignableFrom(appliesToClass)) { try { filter = (AppliesToFilter)appliesToClass.NewInstance(); } catch (Exception e) { throw; //new ConstructionException( e ); } } else if (typeof(Attribute).IsAssignableFrom(appliesToClass)) { filter = new AnnotationAppliesToFilter(appliesToClass); } else // Type check { filter = new TypeCheckAppliesToFilter(appliesToClass); } this.appliesToFilter = this.appliesToFilter == null ? filter : new AndAppliesToFilter(this.appliesToFilter, filter); } } if (this.appliesToFilter == null) { this.appliesToFilter = AppliesToEverything.Instance; } }
private void CreateAppliesToFilter(Type modifierClass) { if (!typeof(InvocationHandler).IsAssignableFrom(modifierClass)) { this.appliesToFilter = new TypedModifierAppliesToFilter(); if (modifierClass.IsAbstract) { this.appliesToFilter = new AndAppliesToFilter(this.appliesToFilter, new ImplementsMethodAppliesToFilter()); } } var appliesTo = modifierClass.GetAttribute<AppliesToAttribute>(); if (appliesTo != null) { foreach (Type appliesToClass in appliesTo.AppliesToTypes) { AppliesToFilter filter; if (typeof(AppliesToFilter).IsAssignableFrom(appliesToClass)) { try { filter = (AppliesToFilter)appliesToClass.NewInstance(); } catch (Exception e) { throw; //new ConstructionException( e ); } } else if (typeof(Attribute).IsAssignableFrom(appliesToClass)) { filter = new AnnotationAppliesToFilter(appliesToClass); } else // Type check { filter = new TypeCheckAppliesToFilter(appliesToClass); } this.appliesToFilter = this.appliesToFilter == null ? filter : new AndAppliesToFilter(this.appliesToFilter, filter); } } if (this.appliesToFilter == null) { this.appliesToFilter = AppliesToEverything.Instance; } }