當前位置: 首頁>>代碼示例>>C#>>正文


C# Proxy.Go方法代碼示例

本文整理匯總了C#中System.Proxy.Go方法的典型用法代碼示例。如果您正苦於以下問題:C# Proxy.Go方法的具體用法?C# Proxy.Go怎麽用?C# Proxy.Go使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Proxy的用法示例。


在下文中一共展示了Proxy.Go方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Throws_If_Target_Is_Null

        public void Throws_If_Target_Is_Null()
        {
            Foo foo = null;
            var proxy = new Proxy<IFoo>()
                .Intercept(f => f.Go())
                .OnInvoke(mi => foo.Go())
                .Save();

            // TODO: Validate that the target isn't null, action.Target doesn't work, it means that the method is static.
            Assert.Throws<NullReferenceException>(() => proxy.Go());
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:11,代碼來源:IssuesReport.cs

示例2: Can_Intercept_Virtual_Methods

        public void Can_Intercept_Virtual_Methods()
        {
            var foo = new Foo();
            var proxy = new Proxy<Foo>()
                .Target(foo)
                .InterceptMethod(f => f.Go())
                .OnBefore(() => Assert.False(foo.WasExecuted))
                .Save();

            proxy.Go();
            Assert.True(foo.WasExecuted);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:12,代碼來源:VirtualMethodInterceptionTester.cs

示例3: Can_Callback_OnAfter

        public void Can_Callback_OnAfter()
        {
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Intercept(f => f.Go())
                .OnInvoke(mi => foo.Go())
                .OnAfter(() => Assert.True(foo.WasExecuted))
                .Save();

            Assert.False(foo.WasExecuted);
            proxy.Go();
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:12,代碼來源:MethodInterceptionTester.cs

示例4: Can_Callback_OnBefore_OnFinally_And_OnAfter

        public void Can_Callback_OnBefore_OnFinally_And_OnAfter()
        {
            var ack = 0;
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Intercept(f => f.Go())
                .OnBefore(() => { ack++; Assert.False(foo.WasExecuted); })
                .OnInvoke(mi => foo.Go())
                .OnFinally(() => ack++)
                .OnAfter(() => { ack++; Assert.True(foo.WasExecuted); })
                .Save();

            proxy.Go();
            Assert.Equal(3, ack);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:15,代碼來源:MethodInterceptionTester.cs

示例5: Can_Intercept_Multiple_Methods_Using_A_Filter

        public void Can_Intercept_Multiple_Methods_Using_A_Filter()
        {
            var ack = 0;
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Target(foo)
                .InterceptWhere(mi => mi.Name.EndsWith("Go"))
                //.InterceptWhere(mi => mi.IsGenericMethod )
                .OnBefore(mi => ack++)
                .Save();

            // intercepted
            proxy.Go();
            proxy.GenericGo<int>(-1);
            proxy.OverloadedGo(-1);
            proxy.OverloadedGo(string.Empty);

            // not intercepted
            proxy.Name = string.Empty;
            proxy.Return();

            Assert.Equal(4, ack);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:23,代碼來源:MethodInterceptionTester.cs

示例6: Can_Intercept_Multiple_Members_Using_A_Single_Fluent_Instruction

        public void Can_Intercept_Multiple_Members_Using_A_Single_Fluent_Instruction()
        {
            var ack = 0;
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Target(foo)
                .InterceptMethod(f => f.Go())
                    .OnBefore(() => Assert.Equal(0, ack))
                    .OnAfter(() => ack++)
                .InterceptGetter(f => f.Name)
                    .OnBefore(() => Assert.Equal(1, ack))
                    .OnAfter(() => ack++)
                .InterceptSetter(f => f.Description)
                    .OnBefore(() => Assert.Equal(2, ack))
                    .OnAfter(() => ack++)
                .Save();

            // intercepted
            proxy.Go();
            var name = proxy.Name;
            proxy.Description = string.Empty;

            // not intercpted
            proxy.Return();
            proxy.Name = string.Empty;
            var desc = proxy.Description;

            Assert.Equal(3, ack);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:29,代碼來源:MethodInterceptionTester.cs

示例7: Can_Intercept_Many_Methods_With_One_Advice

        public void Can_Intercept_Many_Methods_With_One_Advice()
        {
            var ack = 0;
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Target(foo)
                .InterceptMethods(
                    f => f.Return(),
                    f => f.GenericGo<int>(It.Any<int>()),
                    f => f.Go())
                .OnBefore(mi => ack++)
                .Save();

            // intercepted
            proxy.Go();
            proxy.Return();
            proxy.GenericGo<int>(-1);

            // not intercepted
            proxy.Name = string.Empty;
            proxy.OverloadedGo(-1);
            proxy.OverloadedGo(string.Empty);

            Assert.Equal(3, ack);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:25,代碼來源:MethodInterceptionTester.cs

示例8: Can_Intercept_All_Methods_Getters_And_Setters

        public void Can_Intercept_All_Methods_Getters_And_Setters()
        {
            var ack = 0;
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Target(foo)
                .InterceptAll()
                .OnFinally(() => { ack++; })
                .Save();

            // intercepts all gettrers, setters and methods...
            proxy.Go();
            var name = proxy.Name;
            var description = proxy.Description;
            proxy.Name = string.Empty;
            var result = proxy.GenericGo<int>(-1);
            Assert.Equal(5, ack);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:18,代碼來源:MethodInterceptionTester.cs

示例9: Can_Infer_Target_Method_If_A_Target_Object_Exists

        public void Can_Infer_Target_Method_If_A_Target_Object_Exists()
        {
            var foo = new Foo();
            var proxy = new Proxy<IFoo>()
                .Target(foo)
                .Intercept(f => f.Go())
                .OnBefore(() => Assert.False(foo.WasExecuted))
                //.OnInvoke(mi => foo.Go()) must be inferred from context
                .Save();

            proxy.Go();
            Assert.True(foo.WasExecuted);
        }
開發者ID:nvegamarrero,項目名稱:fluentAOP,代碼行數:13,代碼來源:MethodInterceptionTester.cs


注:本文中的System.Proxy.Go方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。