• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Interceptors.LogInvocationInterceptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Castle.DynamicProxy.Tests.Interceptors.LogInvocationInterceptor的典型用法代码示例。如果您正苦于以下问题:C# LogInvocationInterceptor类的具体用法?C# LogInvocationInterceptor怎么用?C# LogInvocationInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LogInvocationInterceptor类属于Castle.DynamicProxy.Tests.Interceptors命名空间,在下文中一共展示了LogInvocationInterceptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: InterfaceInheritance

		public void InterfaceInheritance()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			IService service = (IExtendedService)
			                   generator.CreateInterfaceProxyWithTarget(
			                   	typeof(IExtendedService), new ServiceImpl(), logger);

			Assert.AreEqual(3, service.Sum(1, 2));

			Assert.AreEqual("Sum ", logger.LogContents);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:BasicInterfaceProxyTestCase.cs


示例2: ProtectedMethods

		public void ProtectedMethods()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			NonPublicMethodsClass proxy = (NonPublicMethodsClass)
										  generator.CreateClassProxy(typeof(NonPublicMethodsClass), logger);

			proxy.DoSomething();
			Assert.AreEqual(2, logger.Invocations.Count);
			Assert.AreEqual("DoSomething", logger.Invocations[0]);
			Assert.AreEqual("DoOtherThing", logger.Invocations[1]);
		}
开发者ID:jeremymeng,项目名称:Core,代码行数:12,代码来源:AccessLevelTestCase.cs


示例3: BasicInterfaceProxyWithValidTarget2

		public void BasicInterfaceProxyWithValidTarget2()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			IService2 service = (IService2)
			                    generator.CreateInterfaceProxyWithTarget(
			                    	typeof(IService2), new Service2(), logger);

			service.DoOperation2();

			Assert.AreEqual("DoOperation2 ", logger.LogContents);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:BasicInterfaceProxyTestCase.cs


示例4: ExplicitInterfaceMethods_AreIgnored_OnClassProxy

		public void ExplicitInterfaceMethods_AreIgnored_OnClassProxy()
		{
			LogInvocationInterceptor interceptor = new LogInvocationInterceptor();
			ClassWithExplicitInterface instance = generator.CreateClassProxy<ClassWithExplicitInterface>(interceptor);

			instance.DoVirtual();
			int result = ((ISimpleInterface) instance).Do ();
			instance.DoVirtual();

			Assert.AreEqual(2, interceptor.Invocations.Count);
			Assert.AreEqual("DoVirtual", interceptor.Invocations[0]);
			Assert.AreEqual("DoVirtual", interceptor.Invocations[1]);

			Assert.AreEqual(5, result);
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:15,代码来源:ExplicitInterfaceTestCase.cs


示例5: HookIsUsedForConcreteClassProxy

		public void HookIsUsedForConcreteClassProxy()
		{
			var logger = new LogInvocationInterceptor();
			var hook = new LogHook(typeof(ServiceClass), true);

			var options = new ProxyGenerationOptions(hook);

			var proxy = (ServiceClass)generator.CreateClassProxy(typeof(ServiceClass), options, logger);

			Assert.IsTrue(hook.Completed);
			Assert.AreEqual(13, hook.AskedMembers.Count, "Asked members");
			Assert.AreEqual(2, hook.NonVirtualMembers.Count, "Non-virtual members");

			proxy.Sum(1, 2);
			Assert.IsFalse(proxy.Valid);

			Assert.AreEqual("get_Valid ", logger.LogContents);
		}
开发者ID:elevine,项目名称:Core,代码行数:18,代码来源:GenerationHookTestCase.cs


示例6: HookIsUsedForConcreteClassProxy

		public void HookIsUsedForConcreteClassProxy()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();
			LogHook hook = new LogHook(typeof (ServiceClass), true);

			ProxyGenerationOptions options = new ProxyGenerationOptions(hook);

			ServiceClass proxy = (ServiceClass) generator.CreateClassProxy(typeof (ServiceClass), options, logger);

			Assert.IsTrue(hook.Completed);
			Assert.AreEqual(10, hook.AskedMembers.Count, "Asked members");

			Assert.AreEqual(2, hook.NonVirtualMembers.Count, "Non-virtual members");// <-- this would fail due to superfulous method check

			proxy.Sum(1, 2);
			Assert.IsFalse(proxy.Valid);

			Assert.AreEqual("get_Valid ", logger.LogContents);
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:19,代码来源:GenerationHookTestCase.cs


示例7: ExplicitInterface_AsAdditionalInterfaceToProxy_OnClassProxy_WithoutBaseCalls

		public void ExplicitInterface_AsAdditionalInterfaceToProxy_OnClassProxy_WithoutBaseCalls()
		{
			LogInvocationInterceptor interceptor = new LogInvocationInterceptor ();
			interceptor.Proceed = false;

			ClassWithExplicitInterface instance = (ClassWithExplicitInterface) generator.CreateClassProxy (typeof (ClassWithExplicitInterface),
				new[] { typeof (ISimpleInterface) }, interceptor);

			instance.DoVirtual ();
			int result = ((ISimpleInterface) instance).Do ();
			instance.DoVirtual ();

			Assert.AreEqual (3, interceptor.Invocations.Count);
			Assert.AreEqual ("DoVirtual", interceptor.Invocations[0]);
			Assert.AreEqual ("Do", interceptor.Invocations[1]);
			Assert.AreEqual ("DoVirtual", interceptor.Invocations[2]);

			Assert.AreEqual (0, result); // indicates that original method was not called
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:19,代码来源:ExplicitInterfaceTestCase.cs


示例8: HookDetectsNonVirtualAlthoughInterfaceImplementation

		public void HookDetectsNonVirtualAlthoughInterfaceImplementation()
		{
			var logger = new LogInvocationInterceptor();
			var hook = new LogHook(typeof(ServiceImpl), true);

			var options = new ProxyGenerationOptions(hook);

			// we are creating a class proxy although the creation of an interface proxy is possible too...
			// since the members of our implementation are not explicitly marked as virtual, the runtime
			// marks them as virtual but final --> not good for us, but intended by .net :-(
			//
			// see: https://msdn.microsoft.com/library/system.reflection.methodbase.isvirtual
			//
			// thus, a non virtual notification for this particular situation is appropriate
			generator.CreateClassProxy(typeof(ServiceImpl), options, logger);

			Assert.IsTrue(hook.Completed);
			Assert.AreEqual(3, hook.AskedMembers.Count);
			Assert.AreEqual(11, hook.NonVirtualMembers.Count);
		}
开发者ID:castleproject,项目名称:Core,代码行数:20,代码来源:GenerationHookTestCase.cs


示例9: HookIsUsedForInterfaceProxy

		public void HookIsUsedForInterfaceProxy()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();
			LogHook hook = new LogHook(typeof (IService), false);

			ProxyGenerationOptions options = new ProxyGenerationOptions(hook);

			IService proxy = (IService)
			                 generator.CreateInterfaceProxyWithTarget(
			                 	typeof (IService), new ServiceImpl(), options, logger);

			Assert.IsTrue(hook.Completed);
			Assert.AreEqual(10, hook.AskedMembers.Count);
			Assert.AreEqual(0, hook.NonVirtualMembers.Count);

			Assert.AreEqual(3, proxy.Sum(1, 2));
			Assert.IsFalse(proxy.Valid);

			Assert.AreEqual("Sum get_Valid ", logger.LogContents);
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:20,代码来源:GenerationHookTestCase.cs


示例10: ClassWithDifferentAccessLevelOnProperties

		public void ClassWithDifferentAccessLevelOnProperties()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			object proxy = generator.CreateClassProxy(typeof(DiffAccessLevelOnProperties), logger);

			Assert.IsNotNull(proxy);
			Assert.IsInstanceOfType(typeof(DiffAccessLevelOnProperties), proxy);

			DiffAccessLevelOnProperties type = (DiffAccessLevelOnProperties)proxy;

			type.SetProperties();

			Assert.AreEqual("10 11 12 13 name", type.ToString());
		}
开发者ID:ralescano,项目名称:castle,代码行数:15,代码来源:BasicClassProxyTestCase.cs


示例11: ChangingInvocationTargetSucceeds

		public void ChangingInvocationTargetSucceeds()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			IService service = (IService)
			                   generator.CreateInterfaceProxyWithTargetInterface(
			                   	typeof(IService), new AlwaysThrowsServiceImpl(), new ChangeTargetInterceptor(new ServiceImpl()),
			                   	logger);

			Assert.AreEqual(20, service.Sum(10, 10));
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:11,代码来源:BasicInterfaceProxyTestCase.cs


示例12: InterfaceTargetTypeProducesInvocationsThatCanChangeTarget

		public void InterfaceTargetTypeProducesInvocationsThatCanChangeTarget()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();
			AssertCanChangeTargetInterceptor invocationChecker = new AssertCanChangeTargetInterceptor();

			IService2 service = (IService2)
			                    generator.CreateInterfaceProxyWithTargetInterface(
			                    	typeof(IService2), new Service2(), invocationChecker, logger);

			service.DoOperation2();

			Assert.AreEqual("DoOperation2 ", logger.LogContents);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:13,代码来源:BasicInterfaceProxyTestCase.cs


示例13: ProxyForClassWithIndexer

		public void ProxyForClassWithIndexer()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			object proxy = generator.CreateClassProxy(typeof(ClassWithIndexer), logger);

			Assert.IsNotNull(proxy);
			Assert.IsInstanceOfType(typeof(ClassWithIndexer), proxy);

			ClassWithIndexer type = (ClassWithIndexer)proxy;

			type["name"] = 10;
			Assert.AreEqual(10, type["name"]);

			Assert.AreEqual("set_Item get_Item ", logger.LogContents);
		}
开发者ID:ralescano,项目名称:castle,代码行数:16,代码来源:BasicClassProxyTestCase.cs


示例14: ProxyTypeWithMultiDimentionalArrayAsParameters

		public void ProxyTypeWithMultiDimentionalArrayAsParameters()
		{
			LogInvocationInterceptor log = new LogInvocationInterceptor();

			ClassWithMultiDimentionalArray proxy =
				generator.CreateClassProxy<ClassWithMultiDimentionalArray>(log);

			int[,] x = new int[1,2];

			proxy.Do(new int[] {1});
			proxy.Do2(x);
			proxy.Do3(new string[] {"1", "2"});

			Assert.AreEqual("Do Do2 Do3 ", log.LogContents);
		}
开发者ID:ralescano,项目名称:castle,代码行数:15,代码来源:BasicClassProxyTestCase.cs


示例15: ProxyForCharReturnType

		public void ProxyForCharReturnType()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();
			object proxy = generator.CreateClassProxy(typeof(ClassWithCharRetType), logger);
			Assert.IsNotNull(proxy);
			ClassWithCharRetType classProxy = (ClassWithCharRetType)proxy;
			Assert.AreEqual('c', classProxy.DoSomething());
		}
开发者ID:ralescano,项目名称:castle,代码行数:8,代码来源:BasicClassProxyTestCase.cs


示例16: Indexer

		public void Indexer()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			InterfaceWithIndexer service = (InterfaceWithIndexer)
			                               generator.CreateInterfaceProxyWithTarget(
			                               	typeof(InterfaceWithIndexer), new ClassWithIndexer(), logger);

			Assert.AreEqual(1, service[1]);

			Assert.AreEqual("get_Item ", logger.LogContents);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:BasicInterfaceProxyTestCase.cs


示例17: ExplicitInterface_properties_should_be_public_class

		public void ExplicitInterface_properties_should_be_public_class()
		{
			var interceptor = new LogInvocationInterceptor { Proceed = false };

			var proxy = generator.CreateClassProxy(typeof(ExplicitInterfaceWithPropertyImplementation), new[] { typeof(ISimpleInterfaceWithProperty) },
			                                       interceptor);
			Assert.IsNotEmpty(proxy.GetType().GetProperties());
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:8,代码来源:ExplicitInterfaceTestCase.cs


示例18: ExplicitInterface_properties_should_be_public_interface

		public void ExplicitInterface_properties_should_be_public_interface()
		{
			var interceptor = new LogInvocationInterceptor { Proceed = false };

			var proxy = generator.CreateInterfaceProxyWithoutTarget(typeof(ISimpleInterfaceWithProperty), interceptor);
			Assert.IsNotEmpty(proxy.GetType().GetProperties());
		}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:7,代码来源:ExplicitInterfaceTestCase.cs


示例19: Init

		public override void Init()
		{
			base.Init();
			logger = new LogInvocationInterceptor();
		}
开发者ID:leloulight,项目名称:Core,代码行数:5,代码来源:GenericInterfaceProxyTestCase.cs


示例20: ClassWithInheritance

		public void ClassWithInheritance()
		{
			LogInvocationInterceptor logger = new LogInvocationInterceptor();

			object proxy = generator.CreateClassProxy(typeof(ExtendedServiceClass), logger);

			Assert.IsNotNull(proxy);

			ExtendedServiceClass extended = (ExtendedServiceClass)proxy;

			extended.Sum2(1, 2);
			extended.Sum(1, 2);

			Assert.AreEqual("Sum2 Sum ", logger.LogContents);
		}
开发者ID:ralescano,项目名称:castle,代码行数:15,代码来源:BasicClassProxyTestCase.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# MicroKernel.CreationContext类代码示例发布时间:2022-05-24
下一篇:
C# Interceptors.KeepDataInterceptor类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap