public void ApplyAllPolicies(Type pluginType, Policies policies) { lock (_buildLock) { policies.Apply(pluginType, this); } }
public void select_interceptors() { var activator1 = new ActivatorInterceptor<ITarget>(x => x.Activate()); var activator2 = new ActivatorInterceptor<Target>(x => x.UseSession(null)); var activator3 = new ActivatorInterceptor<Target>(x => x.ThrowUp()); var activator4 = new ActivatorInterceptor<ITarget>(x => x.Debug()); var activator5 = new ActivatorInterceptor<IGateway>(x => x.DoSomething()); var policies = new Policies(); policies.Add(activator1.ToPolicy()); policies.Add(activator2.ToPolicy()); policies.Add(activator3.ToPolicy()); policies.Add(activator4.ToPolicy()); policies.Add(activator5.ToPolicy()); var instance1 = new SmartInstance<Target>(); policies.Apply(typeof(ITarget), instance1); instance1.Interceptors .ShouldHaveTheSameElementsAs(activator1, activator2, activator3, activator4); var instance2 = new SmartInstance<ATarget>(); policies.Apply(typeof(ITarget), instance2); instance2.Interceptors .ShouldHaveTheSameElementsAs(activator1, activator4); var instance3 = new SmartInstance<StubbedGateway>(); policies.Apply(typeof(ITarget), instance3); instance3.Interceptors .ShouldHaveTheSameElementsAs(activator5); }
protected virtual IBuildPlan buildPlan(Type pluginType, Policies policies) { try { policies.Apply(pluginType, this); var builderSource = ToBuilder(pluginType, policies); return(new BuildPlan(pluginType, this, builderSource, policies, Interceptors)); } catch (StructureMapException e) { e.Push("Attempting to create a BuildPlan for " + toDescription(pluginType)); throw; } catch (Exception e) { throw new StructureMapBuildPlanException( "Error while trying to create the BuildPlan for {0}.\nPlease check the inner exception".ToFormat( toDescription(pluginType)), e); } }
protected virtual IBuildPlan buildPlan(Type pluginType, Policies policies) { try { policies.Apply(pluginType, this); var builderSource = ToBuilder(pluginType, policies); return new BuildPlan(pluginType, this, builderSource, policies, Interceptors); } catch (StructureMapException e) { e.Push("Attempting to create a BuildPlan for " + toDescription(pluginType)); throw; } catch (Exception e) { throw new StructureMapBuildPlanException( "Error while trying to create the BuildPlan for {0}.\nPlease check the inner exception".ToFormat( toDescription(pluginType)), e); } }