public TSelf Using(IMatchingRule matchingRule) { // The adapter forces the exclusion, but explicitly stating it here for clarity // and in case any thing external looks at the configuration setting ExcludingFields(); return(AddMatchingRule(new ObsoleteMatchingRuleAdapter(matchingRule))); }
/// <summary> /// Create the <see cref="PolicySet"/> based on the configuration settings. /// </summary> /// <param name="context">Builder context.</param> /// <param name="name">Name of object to create.</param> /// <param name="configurationSource">Configuration source.</param> /// <param name="reflectionCache">reflection cache, unused in this method.</param> /// <returns>The constructed <see cref="PolicySet"/> object.</returns> public object CreateObject(IBuilderContext context, string name, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache) { PolicyInjectionSettings injectionSettings = configurationSource.GetSection(PolicyInjectionSettings.SectionName) as PolicyInjectionSettings; if (injectionSettings == null) { return(new PolicySet()); } PolicySet policySet = new PolicySet(); foreach (PolicyData policyData in injectionSettings.Policies) { RuleDrivenPolicy policy = new RuleDrivenPolicy(policyData.Name); foreach (CallHandlerData handlerData in policyData.Handlers) { ICallHandler callHandler = CallHandlerCustomFactory.Instance.Create(context, handlerData, configurationSource, reflectionCache); policy.Handlers.Add(callHandler); } foreach (MatchingRuleData matchingRuleData in policyData.MatchingRules) { IMatchingRule matchingRule = MatchingRuleCustomFactory.Instance.Create(context, matchingRuleData, configurationSource, reflectionCache); policy.RuleSet.Add(matchingRule); } policySet.Add(policy); } return(policySet); }
/// <summary> /// Creates a new <see cref="RuleDrivenPolicy"/> object with a name, a set of matching rules /// and the names to use when resolving handlers. /// </summary> public RuleDrivenPolicy(string name, IMatchingRule[] matchingRules, string[] callHandlerNames) : base(name) { this.ruleSet = new MatchingRuleSet(); this.ruleSet.AddRange(matchingRules); this.callHandlerNames = callHandlerNames; }
void AddValidationPolicy(IUnityContainer factory, string ruleSet, SpecificationSource specificationSource, IMatchingRule matchingRule) { factory.Configure <Interception>().AddPolicy("Noop") .AddMatchingRule(matchingRule) .AddCallHandler(new ValidationCallHandler(ruleSet, specificationSource)); }
public static RuleChaining Or(this RuleChaining rule, IMatchingRule innerCheck) { var checkOtherRule = Expression.Call(Expression.Constant(innerCheck), _methodInfo, source, target); return(new RuleChaining() { Expression = rule.Expression.Or(checkOtherRule) }); }
public static RuleChaining Or(this IMatchingRule rule, RuleChaining innerCheck) { var checkRule = Expression.Call(Expression.Constant(rule), _methodInfo, source, target); return(new RuleChaining() { Expression = checkRule.Or(Expression.Invoke(innerCheck.Expression, source, target)) }); }
public static RuleChaining Or(this IMatchingRule rule, IMatchingRule otherRule) { var checkRule = Expression.Call(Expression.Constant(rule), _methodInfo, source, target); var checkOtherRule = Expression.Call(Expression.Constant(otherRule), _methodInfo, source, target); return(new RuleChaining() { Expression = checkRule.Or(checkOtherRule) }); }
public void AddInterceptor(string policy, IMatchingRule matchingRule, params Type[] classTypes) { Interception interception = uContainer.Configure <Interception>(); foreach (Type classType in classTypes) { interception = interception.SetInterceptorFor(classType, new VirtualMethodInterceptor()); } interception.AddPolicy(policy) .AddMatchingRule(matchingRule); }
public void SetUp() { _processor = new RequestProcessor(_ruleThatReturnsFirstHandler, new RequestHandlerList()); _requestHandlerFactory = new RequestHandlerFactory(_processor); _dataProducer = MockRepository.GenerateStub <IDataProducer>(); _httpResponseDelegate = MockRepository.GenerateStub <IHttpResponseDelegate>(); _ruleThatReturnsFirstHandler = MockRepository.GenerateStub <IMatchingRule>(); _ruleThatReturnsFirstHandler.Stub(x => x.IsEndpointMatch(null, new HttpRequestHead())).IgnoreArguments().Return(true).Repeat.Once(); _ruleThatReturnsNoHandlers = MockRepository.GenerateStub <IMatchingRule>(); _ruleThatReturnsNoHandlers.Stub(x => x.IsEndpointMatch(null, new HttpRequestHead())).IgnoreArguments().Return(false); }
public RequestProcessor(IMatchingRule matchingRule, IRequestHandlerList requestHandlers) { _handlers = requestHandlers; _requestMatcher = new RequestMatcher(matchingRule); }
public RequestMatcher(IMatchingRule matchingRule) { _matchingRule = matchingRule; }
public RequestMatcher(IMatchingRule matchingRule) { _matchingRule = matchingRule; }
/// <summary> /// Creates a new empty policy with the given name. /// </summary> /// <param name="name">Name of the policy.</param> protected InjectionPolicy(string name) { this.name = name; doesNotHaveNoPoliciesAttributeRule = new ApplyNoPoliciesMatchingRule(); }
public CollectionMemberMatchingRuleDecorator(IMatchingRule matchingRule) { this.matchingRule = matchingRule; }
public void SetUp() { _processor = new RequestProcessor(_ruleThatReturnsFirstHandler, new RequestHandlerList()); _requestHandlerFactory = new RequestHandlerFactory(_processor); _dataProducer = MockRepository.GenerateStub<IDataProducer>(); _httpResponseDelegate = MockRepository.GenerateStub<IHttpResponseDelegate>(); _ruleThatReturnsFirstHandler = MockRepository.GenerateStub<IMatchingRule>(); _ruleThatReturnsFirstHandler.Stub(x => x.IsEndpointMatch(null, new HttpRequestHead())).IgnoreArguments().Return(true).Repeat.Once(); _ruleThatReturnsNoHandlers = MockRepository.GenerateStub<IMatchingRule>(); _ruleThatReturnsNoHandlers.Stub(x => x.IsEndpointMatch(null, new HttpRequestHead())).IgnoreArguments().Return(false); }
public ComparisonConfiguration <TSubject> AddRule(IMatchingRule matchingRule) { matchingRules.Add(matchingRule); return(this); }
void AddValidationPolicy(IUnityContainer factory, string ruleSet, SpecificationSource specificationSource, IMatchingRule matchingRule) { factory.Configure<Interception>().AddPolicy("Noop") .AddMatchingRule(matchingRule) .AddCallHandler(new ValidationCallHandler(ruleSet, specificationSource)); }
public ObsoleteMatchingRuleAdapter(IMatchingRule obsoleteMatchingRule) { this.obsoleteMatchingRule = obsoleteMatchingRule; }
/// <summary> /// Adds a matching rule to the ones already added by default, and which is evaluated before all existing rules. /// </summary> public EquivalencyAssertionOptions <TSubject> Using(IMatchingRule matchingRule) { matchingRules.Insert(0, matchingRule); return(this); }
public RequestProcessor(IMatchingRule matchingRule, RequestHandlerList requestHandlers) { _matchingRule = matchingRule; _handlers = requestHandlers; }
/// <summary> /// Creates a new empty policy with the given name. /// </summary> /// <param name="name">Name of the policy.</param> protected InjectionPolicy(string name) { this.name = name; doesNotHaveNoPoliciesAttributeRule = new ApplyNoPoliciesMatchingRule(); }
/// <summary> /// Creates a new <see cref="RuleDrivenPolicy"/> object with a set of matching rules /// and the names to use when resolving handlers. /// </summary> public RuleDrivenPolicy(IMatchingRule[] matchingRules, string[] callHandlerNames) : this("Unnamed policy", matchingRules, callHandlerNames) { }
public RequestProcessor(IMatchingRule matchingRule, IRequestHandlerList requestHandlers) { _handlers = requestHandlers; _requestMatcher = new RequestMatcher(matchingRule); }
/// <summary> /// Makes <paramref name="instance"/> a matching rule in the current policy. /// </summary> /// <param name="instance">The new <see cref="IMatchingRule"/> for the policy.</param> /// <returns> /// The <see cref="PolicyDefinition"/> than allows further configuration of the policy. /// </returns> public PolicyDefinition AddMatchingRule(IMatchingRule instance) { return(AddElement(instance, UpdateRulesParameters)); }
public ObsoleteMatchingRuleAdapter(IMatchingRule obsoleteMatchingRule) { this.obsoleteMatchingRule = obsoleteMatchingRule; }
public RequestProcessor(IMatchingRule matchingRule, ConcurrentDictionary <Guid, RequestHandlerList> requestHandlers) { _handlers = requestHandlers; _requestMatcher = new RequestMatcher(matchingRule); }