当前位置: 首页>>代码示例>>C#>>正文


C# Engine.CreateProxy方法代码示例

本文整理汇总了C#中Engine.CreateProxy方法的典型用法代码示例。如果您正苦于以下问题:C# Engine.CreateProxy方法的具体用法?C# Engine.CreateProxy怎么用?C# Engine.CreateProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Engine的用法示例。


在下文中一共展示了Engine.CreateProxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateProxy

        public void CreateProxy()
        {
            Engine c = new Engine("CreateProxy");

            SomeClass proxy = (SomeClass) c.CreateProxy(typeof (SomeClass));

            Assert.IsTrue(proxy != null, "failed to create proxified instance");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:8,代码来源:Tests.cs

示例2: CreateProxyWithCtorParams

        public void CreateProxyWithCtorParams()
        {
            Engine c = new Engine("CreateProxyWithCtorParams");

            SomeClass proxy = (SomeClass) c.CreateProxy(typeof (SomeClass),555,"hello");

            Assert.IsTrue(proxy != null, "failed to create proxified instance");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:8,代码来源:Tests.cs

示例3: TestCallAsync

		public async Task TestCallAsync ()
		{
			var engine = new Engine();
			var proxy = engine.CreateProxy<ITarget>(new InternalThreadPoolTransport(engine.CreateRequestHandler(new Selector())));

			await proxy.FooAsync();
			Assert.Equal("x1", await proxy.BarAsync("x"));
		}
开发者ID:kekekeks,项目名称:AsyncRpc,代码行数:8,代码来源:EngineTests.cs

示例4: AddException

        public void AddException()
        {
            Engine c = new Engine("AddException");
            c.Configuration.Aspects.Add(new SignatureAspect("RemoveException", typeof (SomeClass), "*", new AddExceptionInterceptor()));

            SomeClass proxy = (SomeClass) c.CreateProxy(typeof (SomeClass));

            proxy.MyExceptionMethod();
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:9,代码来源:Tests.cs

示例5: CallServicedComponentClass

 public void CallServicedComponentClass()
 {
     Engine e = new Engine("CallServicedComponentClass");
     IAroundInterceptor myInterceptor = new MyInterceptor();
     SignatureAspect sa = new SignatureAspect("labb", "*", "*", myInterceptor);
     e.Configuration.Aspects.Add(sa);
     DummyServiced proxy = e.CreateProxy<DummyServiced>();
     proxy.Foo();
 }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:9,代码来源:UnitTest1.cs

示例6: CreateProxyWithCtorParamsWithInterceptor

        public void CreateProxyWithCtorParamsWithInterceptor()
        {
            Engine c = new Engine("CreateProxyWithCtorParamsWithInterceptor");
            c.Configuration.Aspects.Add(new SignatureAspect("ChangeReturnValue", typeof (SomeClass), "*", new ChangeReturnValueInterceptor()));

            SomeClass proxy = (SomeClass) c.CreateProxy(typeof (SomeClass),555,"hello");

            Assert.IsTrue(proxy != null, "failed to create proxified instance");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:9,代码来源:Tests.cs

示例7: ChangeReturnValue

        public void ChangeReturnValue()
        {
            Engine c = new Engine("ChangeReturnValue");
            c.Configuration.Aspects.Add(new SignatureAspect("ChangeReturnValue", typeof (SomeClass), "*", new ChangeReturnValueInterceptor()));

            SomeClass normal = new SomeClass();

            SomeClass proxy = (SomeClass) c.CreateProxy(typeof (SomeClass));

            Assert.IsTrue(normal.MyIntMethod() != proxy.MyIntMethod(), "return value has not been changed");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:11,代码来源:Tests.cs

示例8: ChangeRefParam

        public void ChangeRefParam()
        {
            Engine c = new Engine("ChangeRefParam");
            c.Configuration.Aspects.Add(new SignatureAspect("ChangeRefParam", typeof (SomeClass), "*MyRefParamMethod*", new ChangeRefParamValueInterceptor()));

            SomeClass proxy = (SomeClass) c.CreateProxy(typeof (SomeClass));

            string refString = "some value";
            proxy.MyRefParamMethod(ref refString);

            Assert.IsTrue("some value" != refString, "ref param has not been changed");
            Assert.IsTrue("some changed value" == refString, "ref param has not been set correctly");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:13,代码来源:Tests.cs

示例9: AddExceptionWithMultipleInterceptors

        public void AddExceptionWithMultipleInterceptors()
        {
            Engine c = new Engine("AddExceptionWithMultipleInterceptors");
            c.Configuration.Aspects.Add(new SignatureAspect("Security", typeof (Foo), "*", new SecurityInterceptor()));
            c.Configuration.Aspects.Add(
                new SignatureAspect("Invariant", typeof (Foo), "*MyExceptionMethod*", new InvariantInterceptor()));
            c.Configuration.Aspects.Add(
                new SignatureAspect("RemoveException", typeof (Foo), "*MyExceptionMethod*",
                                    new AddExceptionInterceptor()));

            Foo proxy = c.CreateProxy<Foo>();

            proxy.MyExceptionMethod();
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:14,代码来源:Tests.cs

示例10: DirtyTrackingTest

        public void DirtyTrackingTest()
        {
            Engine c = new Engine("DirtyTrackingTest");
            c.Configuration.Aspects.Add(new DirtyTrackedAspect());

            DirtyTrackedClass d = c.CreateProxy<DirtyTrackedClass>();

            IDirtyTracked dt = d as IDirtyTracked;
            Assert.IsFalse(dt.IsDirty, "object was dirty");
            d.SomeProp = "Hello";
            Assert.IsTrue(dt.IsDirty, "object not was dirty");

            Assert.IsTrue(dt.GetPropertyDirtyStatus("SomeProp"),"SomeProp was not dirty");
            dt.ClearDirty();

            Assert.IsFalse(dt.GetPropertyDirtyStatus("SomeProp"), "SomeProp was dirty");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:17,代码来源:StandardAspectTests.cs

示例11: TypedAspectMixinTest

        public void TypedAspectMixinTest()
        {
            Engine c = new Engine("TypedAspectMixinTest");
            c.Configuration.Aspects.Add(new MyTypedAspect());

            Foo proxy = (Foo)c.CreateProxy(typeof(Foo));

            ISayHello sayHello = (ISayHello)proxy;

            string helloString = sayHello.SayHello();

            Assert.IsTrue(helloString == "Hello", "SayHelloMixin did not work");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:13,代码来源:Tests.cs

示例12: TypedAspectInterceptorTest

        public void TypedAspectInterceptorTest()
        {
            Engine c = new Engine("TypedAspectInterceptorTest");
            c.Configuration.Aspects.Add(new ReturnValueChangerAspect());

            Foo proxy = (Foo)c.CreateProxy(typeof(Foo));

            int result = proxy.MyIntMethod();

            Assert.IsTrue(result == 1, "return value has not been changed");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:11,代码来源:Tests.cs

示例13: RemoveException

        public void RemoveException()
        {
            Engine c = new Engine("RemoveException");
            c.Configuration.Aspects.Add(
                new SignatureAspect("RemoveException", typeof (Foo), "*", new RemoveExceptionInterceptor()));

            Foo proxy = (Foo) c.CreateProxy(typeof (Foo));

            proxy.MyExceptionMethod();
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:10,代码来源:Tests.cs

示例14: ProxyGenericList

        public void ProxyGenericList()
        {
            Engine c = new Engine("ProxyGenericList");
            c.Configuration.Aspects.Add(
                new SignatureAspect("ProxyGenericList", typeof (List<string>), "*Add*", new PassiveInterceptor()));

            List<string> proxy = c.CreateProxy<List<string>>();
            Assert.IsTrue(proxy != null, "Failed to proxy generic list");
            Assert.IsTrue(proxy is IAopProxy, "Failed to proxy generic list");

            proxy.Add("a");
            proxy.Add("b");
            proxy.Add("c");
            proxy.RemoveAt(0);
            proxy.Remove("b");

            IList ilist = proxy;
            ilist.Add("hej");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:19,代码来源:Tests.cs

示例15: ProxyExplicitIFace

        public void ProxyExplicitIFace()
        {
            Engine c = new Engine("ProxyExplicitIFace");
            c.Configuration.Aspects.Add(
                new SignatureAspect("ProxyExplicitIFace", typeof (SomeClassWithExplicitIFace), "*Clone*"
                                    /*<-only Clone */, new ExplicitIFaceClonableInterceptor()));

            SomeClassWithExplicitIFace proxy =
                (SomeClassWithExplicitIFace) c.CreateProxy(typeof (SomeClassWithExplicitIFace));

            ICloneable cloneable = proxy;

            SomeClassWithExplicitIFace res = (SomeClassWithExplicitIFace) cloneable.Clone();

            Assert.IsTrue(res.SomeLongProp == 1234, "Clone interceptor did not work");
        }
开发者ID:BackupTheBerlios,项目名称:puzzle-svn,代码行数:16,代码来源:Tests.cs


注:本文中的Engine.CreateProxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。