Beispiel #1
0
 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('/');
            }
        }
Beispiel #3
0
        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");
            }
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public ProxyFactory(ProxyBehavior behavior) : base(behavior)
 {
 }
Beispiel #6
0
 protected ProxyFactoryBase(ProxyBehavior behavior)
 {
     this.behavior = BehaviorFactory.Create(behavior);
 }