public static IBehavior Create(ProxyBehavior behavior) { switch (behavior) { case ProxyBehavior.Default: case ProxyBehavior.Castle: return new CastleBehavior(); case ProxyBehavior.LinFu: return new LinFuBehavior(); case ProxyBehavior.Spring: return new SpringBehavior(); default: throw new ArgumentException("CIL Provider Unknown", "behavior"); } }
private ProxyConfiguration(ProxyBehavior proxyBehavior, string pathBase) { ProxyBehavior = proxyBehavior; if (string.IsNullOrWhiteSpace(pathBase) || DefaultPathBase.Equals(pathBase)) { IsDefaultPathBase = true; DefaultOrCurrentPathBaseWithoutTrailingSlash = DefaultPathBase; } else { IsDefaultPathBase = false; DefaultOrCurrentPathBaseWithoutTrailingSlash = pathBase.TrimEnd('*').TrimEnd('/'); } }
public static IBehavior Create(ProxyBehavior behavior) { switch (behavior) { case ProxyBehavior.Default: case ProxyBehavior.Castle: return(new CastleBehavior()); case ProxyBehavior.LinFu: return(new LinFuBehavior()); case ProxyBehavior.Spring: return(new SpringBehavior()); default: throw new ArgumentException("CIL Provider Unknown", "behavior"); } }
public void WhenInvokingPipeline_ThenSkipsNonApplicableBehaviors() { var firstCalled = false; var secondCalled = false; var targetCalled = false; var pipeline = new BehaviorPipeline( ProxyBehavior.Create((m, n) => { firstCalled = true; return(n().Invoke(m, n)); }), ProxyBehavior.Create((m, n) => { secondCalled = true; return(n().Invoke(m, n)); }, m => false)); Action a = WhenInvokingPipeline_ThenInvokesAllBehaviorsAndTarget; pipeline.Invoke(new MethodInvocation(this, a.GetMethodInfo()), new InvokeBehavior((m, n) => { targetCalled = true; return(m.CreateValueReturn(null)); })); Assert.True(firstCalled); Assert.False(secondCalled); Assert.True(targetCalled); }
public ProxyFactory(ProxyBehavior behavior) : base(behavior) { }
protected ProxyFactoryBase(ProxyBehavior behavior) { this.behavior = BehaviorFactory.Create(behavior); }