本文整理汇总了C#中Castle.DynamicProxy.Tests.Interceptors.KeepDataInterceptor类的典型用法代码示例。如果您正苦于以下问题:C# KeepDataInterceptor类的具体用法?C# KeepDataInterceptor怎么用?C# KeepDataInterceptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeepDataInterceptor类属于Castle.DynamicProxy.Tests.Interceptors命名空间,在下文中一共展示了KeepDataInterceptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InterfaceProxyWithTarget_MethodInvocationTarget_should_be_null
public void InterfaceProxyWithTarget_MethodInvocationTarget_should_be_null()
{
var interceptor = new KeepDataInterceptor();
var proxy = generator.CreateInterfaceProxyWithoutTarget<IService>(interceptor);
proxy.Sum(2, 2);
Assert.IsNull(interceptor.Invocation.MethodInvocationTarget);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:7,代码来源:InvocationMethodInvocationTargetTestCase.cs
示例2: InvocationForInterfaceProxyWithTarget
public void InvocationForInterfaceProxyWithTarget()
{
KeepDataInterceptor interceptor = new KeepDataInterceptor();
object proxy = generator.CreateInterfaceProxyWithTarget(
typeof (IService), new ServiceImpl(), interceptor);
IService instance = (IService) proxy;
instance.Sum(20, 25);
Assert.IsNotNull(interceptor.Invocation);
Assert.IsNotNull(interceptor.Invocation.Arguments);
Assert.AreEqual(2, interceptor.Invocation.Arguments.Length);
Assert.AreEqual(20, interceptor.Invocation.Arguments[0]);
Assert.AreEqual(25, interceptor.Invocation.Arguments[1]);
Assert.AreEqual(20, interceptor.Invocation.GetArgumentValue(0));
Assert.AreEqual(25, interceptor.Invocation.GetArgumentValue(1));
Assert.AreEqual(45, interceptor.Invocation.ReturnValue);
Assert.IsNotNull(interceptor.Invocation.Proxy);
Assert.IsNotInstanceOf(typeof(ServiceImpl), interceptor.Invocation.Proxy);
Assert.IsNotNull(interceptor.Invocation.InvocationTarget);
Assert.IsInstanceOf(typeof(ServiceImpl), interceptor.Invocation.InvocationTarget);
Assert.IsNotNull(interceptor.Invocation.TargetType);
Assert.AreSame(typeof(ServiceImpl), interceptor.Invocation.TargetType);
Assert.IsNotNull(interceptor.Invocation.Method);
Assert.IsNotNull(interceptor.Invocation.MethodInvocationTarget);
Assert.AreNotSame(interceptor.Invocation.Method, interceptor.Invocation.MethodInvocationTarget);
}
开发者ID:leloulight,项目名称:Core,代码行数:33,代码来源:InvocationTestCase.cs
示例3: InvocationForConcreteClassProxy
public void InvocationForConcreteClassProxy()
{
KeepDataInterceptor interceptor = new KeepDataInterceptor();
object proxy = generator.CreateClassProxy(typeof (ServiceClass), interceptor);
ServiceClass instance = (ServiceClass) proxy;
instance.Sum(20, 25);
Assert.IsNotNull(interceptor.Invocation);
Assert.IsNotNull(interceptor.Invocation.Arguments);
Assert.AreEqual(2, interceptor.Invocation.Arguments.Length);
Assert.AreEqual(20, interceptor.Invocation.Arguments[0]);
Assert.AreEqual(25, interceptor.Invocation.Arguments[1]);
Assert.AreEqual(20, interceptor.Invocation.GetArgumentValue(0));
Assert.AreEqual(25, interceptor.Invocation.GetArgumentValue(1));
Assert.AreEqual(45, interceptor.Invocation.ReturnValue);
Assert.IsNotNull(interceptor.Invocation.Proxy);
Assert.IsInstanceOf(typeof (ServiceClass), interceptor.Invocation.Proxy);
Assert.IsNotNull(interceptor.Invocation.InvocationTarget);
Assert.IsInstanceOf(typeof (ServiceClass), interceptor.Invocation.InvocationTarget);
Assert.IsNotNull(interceptor.Invocation.TargetType);
Assert.AreSame(typeof (ServiceClass), interceptor.Invocation.TargetType);
Assert.IsNotNull(interceptor.Invocation.Method);
Assert.IsNotNull(interceptor.Invocation.MethodInvocationTarget);
Assert.AreSame(interceptor.Invocation.Method, interceptor.Invocation.MethodInvocationTarget.GetBaseDefinition());
}
开发者ID:leloulight,项目名称:Core,代码行数:32,代码来源:InvocationTestCase.cs
示例4: ClassProxy_MethodInvocationTarget_should_be_base_Method_for_interface_methods_implemented_virtually
public void ClassProxy_MethodInvocationTarget_should_be_base_Method_for_interface_methods_implemented_virtually()
{
var interceptor = new KeepDataInterceptor();
var proxy = generator.CreateClassProxy(typeof(ClassWithVirtualInterface), new[] { typeof(ISimpleInterface) }, interceptor) as ISimpleInterface;
proxy.Do();
var methodOnClass = typeof(ClassWithVirtualInterface).GetMethod("Do", Type.EmptyTypes);
Assert.AreSame(methodOnClass, interceptor.Invocation.MethodInvocationTarget);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:InvocationMethodInvocationTargetTestCase.cs
示例5: KeepDataInterceptor
public void ClassProxy_MethodInvocationTarget_should_be_base_Method_for_interface_methods_implemented_non_virtually()
{
var interceptor = new KeepDataInterceptor();
var proxy = generator.CreateClassProxy(typeof(One), new[] { typeof(IOne) }, interceptor) as IOne;
proxy.OneMethod();
var methodOnInterface = typeof(One).GetMethod("OneMethod", Type.EmptyTypes);
Assert.AreSame(methodOnInterface, interceptor.Invocation.MethodInvocationTarget);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:InvocationMethodInvocationTargetTestCase.cs
示例6: ClassProxy_MethodInvocationTarget_should_be_base_Method
public void ClassProxy_MethodInvocationTarget_should_be_base_Method()
{
var interceptor = new KeepDataInterceptor();
var proxy = generator.CreateClassProxy<ServiceClass>(interceptor);
proxy.Sum(2, 2);
var methodOnClass = typeof(ServiceClass).GetMethod("Sum", new[] { typeof(int), typeof(int) });
Assert.AreSame(methodOnClass, interceptor.Invocation.MethodInvocationTarget);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:8,代码来源:InvocationMethodInvocationTargetTestCase.cs
示例7: InterfaceProxyWithTargetInterface_MethodInvocationTarget_should_be_methodOnTargetType
public void InterfaceProxyWithTargetInterface_MethodInvocationTarget_should_be_methodOnTargetType()
{
var interceptor = new KeepDataInterceptor();
var target = new ServiceImpl();
var proxy = generator.CreateInterfaceProxyWithTargetInterface(typeof(IService), target, interceptor) as IService;
proxy.Sum(2, 2);
MethodInfo methodOnTarget = target.GetType().GetMethod("Sum", new[] { typeof(int), typeof(int) });
Assert.AreSame(methodOnTarget, interceptor.Invocation.MethodInvocationTarget);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:9,代码来源:InvocationMethodInvocationTargetTestCase.cs
示例8: Should_share_invocations_for_interface_methods
public void Should_share_invocations_for_interface_methods()
{
var interceptor1 = new KeepDataInterceptor();
var interceptor2 = new KeepDataInterceptor();
var first = generator.CreateInterfaceProxyWithTarget<IOne>(new One(), interceptor1);
var second = generator.CreateInterfaceProxyWithTarget<IOne>(new OneTwo(), interceptor2);
Assert.AreNotEqual(first.GetType(), second.GetType(), "proxy types are different");
first.OneMethod();
second.OneMethod();
Assert.AreEqual(interceptor1.Invocation.GetType(), interceptor2.Invocation.GetType());
}
开发者ID:leloulight,项目名称:Core,代码行数:14,代码来源:InvocationTypesCachingTestCase.cs
示例9: GenericMethod_WithConstraintOnSurroundingTypeParameter
public void GenericMethod_WithConstraintOnSurroundingTypeParameter ()
{
Type type = typeof (IGenericInterfaceWithGenericMethodWithDependentConstraint<object>);
KeepDataInterceptor interceptor = new KeepDataInterceptor ();
IGenericInterfaceWithGenericMethodWithDependentConstraint<object> proxy = (IGenericInterfaceWithGenericMethodWithDependentConstraint<object>)
generator.CreateInterfaceProxyWithoutTarget(type, new Type[] { }, interceptor);
proxy.RegisterType<string> ();
MethodInfo expectedMethod =
typeof (IGenericInterfaceWithGenericMethodWithDependentConstraint<object>).GetMethod ("RegisterType").MakeGenericMethod (typeof (string));
Assert.AreEqual (expectedMethod, interceptor.Invocation.Method);
}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:15,代码来源:GenericMethodsProxyTestCase.cs
示例10: Should_not_share_invocations_for_interface_methods_when_one_is_IChangeProxyTarget
public void Should_not_share_invocations_for_interface_methods_when_one_is_IChangeProxyTarget()
{
var interceptor1 = new KeepDataInterceptor();
var interceptor2 = new KeepDataInterceptor();
var first = generator.CreateInterfaceProxyWithTarget<IOne>(new One(), interceptor1);
var second = generator.CreateInterfaceProxyWithTargetInterface<IOne>(new OneTwo(), interceptor2);
Assert.AreNotEqual(first.GetType(), second.GetType(), "proxy types are different");
first.OneMethod();
second.OneMethod();
Assert.IsNotInstanceOf<IChangeProxyTarget>(interceptor1.Invocation);
Assert.IsInstanceOf<IChangeProxyTarget>(interceptor2.Invocation);
Assert.AreNotEqual(interceptor1.Invocation.GetType(), interceptor2.Invocation.GetType());
}
开发者ID:leloulight,项目名称:Core,代码行数:16,代码来源:InvocationTypesCachingTestCase.cs
示例11: GenericMethod_WithConstraintOnOtherParameter
public void GenericMethod_WithConstraintOnOtherParameter()
{
var type = typeof(IInterfaceWithGenericMethodWithDependentConstraint);
var interceptor = new KeepDataInterceptor();
var proxy = (IInterfaceWithGenericMethodWithDependentConstraint)
generator.CreateInterfaceProxyWithoutTarget(type, new Type[] { }, interceptor);
proxy.RegisterType<object, string>();
var expectedMethod =
typeof(IInterfaceWithGenericMethodWithDependentConstraint).GetMethod("RegisterType").MakeGenericMethod(
typeof(object), typeof(string));
Assert.AreEqual(expectedMethod, interceptor.Invocation.Method);
}
开发者ID:jeremymeng,项目名称:Core,代码行数:16,代码来源:GenericMethodsProxyTestCase.cs
示例12: MethodInfoClosedInGenTypeNongenMethodValueTypeRefType
public void MethodInfoClosedInGenTypeNongenMethodValueTypeRefType()
{
KeepDataInterceptor interceptor = new KeepDataInterceptor();
GenClassWithGenReturn<int, List<object>> proxy =
generator.CreateClassProxy<GenClassWithGenReturn<int, List<object>>>(interceptor);
proxy.DoSomethingT();
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof (int));
Assert.AreEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget().GetBaseDefinition());
proxy.DoSomethingZ();
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof (List<object>));
Assert.AreEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget().GetBaseDefinition());
}
开发者ID:JulianBirch,项目名称:Castle.Core,代码行数:16,代码来源:GenericClassProxyTestCase.cs
示例13: ThrowsWhenProxyingGenericTypeDefNoTarget
public void ThrowsWhenProxyingGenericTypeDefNoTarget()
{
var interceptor = new KeepDataInterceptor();
Assert.Throws<GeneratorException>(() =>
generator.CreateInterfaceProxyWithoutTarget(typeof(IGenInterfaceHierarchyBase<>), interceptor)
);
}
开发者ID:elevine,项目名称:Core,代码行数:8,代码来源:GenericInterfaceProxyTestCase.cs
示例14: ThrowsWhenProxyingGenericTypeDefNoTarget
public void ThrowsWhenProxyingGenericTypeDefNoTarget()
{
KeepDataInterceptor interceptor = new KeepDataInterceptor();
Assert.Throws<GeneratorException>(delegate {
generator.CreateClassProxy(typeof(GenClassWithGenReturn<,>), interceptor);
});
}
开发者ID:castleproject,项目名称:Core,代码行数:8,代码来源:GenericClassProxyTestCase.cs
示例15: MethodInfoClosedInGenTypeGenMethodValueType
public void MethodInfoClosedInGenTypeGenMethodValueType()
{
KeepDataInterceptor interceptor = new KeepDataInterceptor();
GenClassWithGenMethods<int> proxy = generator.CreateClassProxy<GenClassWithGenMethods<int>>(interceptor);
proxy.DoSomething(1);
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof (int), typeof (int));
Assert.AreEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
proxy.DoSomething(new List<object>());
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof (int),
typeof (List<object>));
Assert.AreEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
}
开发者ID:ralescano,项目名称:castle,代码行数:16,代码来源:GenericClassProxyTestCase.cs
示例16: MethodInfoClosedInGenIfcNongenMethodRefTypeWithTarget
public void MethodInfoClosedInGenIfcNongenMethodRefTypeWithTarget()
{
KeepDataInterceptor interceptor = new KeepDataInterceptor();
IGenInterfaceHierarchyBase<List<object>> target = new GenInterfaceHierarchy<List<object>>();
IGenInterfaceHierarchyBase<List<object>> proxy =
generator.CreateInterfaceProxyWithTarget<IGenInterfaceHierarchyBase<List<object>>>(target, interceptor);
proxy.Add(null);
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(void),
typeof(List<object>));
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethodInvocationTarget(), typeof(void),
typeof(List<object>));
Assert.AreNotEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
proxy.Get();
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(List<object>));
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethodInvocationTarget(),
typeof(List<object>));
Assert.AreNotEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
}
开发者ID:ralescano,项目名称:castle,代码行数:22,代码来源:GenericInterfaceProxyTestCase.cs
示例17: ChangeProxyTarget_should_not_affect_invocation_target
public void ChangeProxyTarget_should_not_affect_invocation_target()
{
var first = new ChangeProxyTargetInterceptor(new OneTwo());
var second = new KeepDataInterceptor();
var proxy = generator.CreateInterfaceProxyWithTargetInterface<IOne>(new One(),
first,
second);
proxy.OneMethod();
Assert.AreEqual(typeof(One), second.Invocation.InvocationTarget.GetType());
}
开发者ID:gitter-badger,项目名称:Core-8,代码行数:12,代码来源:InterfaceProxyWithTargetInterfaceTestCase.cs
示例18: MethodInfoClosedInNongenIfcGenMethodWithTarget
public void MethodInfoClosedInNongenIfcGenMethodWithTarget()
{
var interceptor = new KeepDataInterceptor();
OnlyGenMethodsInterface target = new OnlyGenMethodsInterfaceImpl();
var proxy =
generator.CreateInterfaceProxyWithTarget(target, interceptor);
proxy.DoSomething(1);
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(int), typeof(int));
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethodInvocationTarget(), typeof(int),
typeof(int));
Assert.AreNotEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
proxy.DoSomething(new List<object>());
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(List<object>),
typeof(List<object>));
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethodInvocationTarget(),
typeof(List<object>), typeof(List<object>));
Assert.AreNotEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
}
开发者ID:leloulight,项目名称:Core,代码行数:22,代码来源:GenericInterfaceProxyTestCase.cs
示例19: MethodInfoClosedInGenIfcGenMethodRefTypeWithTarget
public void MethodInfoClosedInGenIfcGenMethodRefTypeWithTarget()
{
var interceptor = new KeepDataInterceptor();
GenInterfaceWithGenMethods<List<object>> target = new GenInterfaceWithGenMethodsImpl<List<object>>();
var proxy =
generator.CreateInterfaceProxyWithTarget(target, interceptor);
proxy.DoSomething(1, null);
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(void), typeof(int),
typeof(List<object>));
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethodInvocationTarget(), typeof(void),
typeof(int), typeof(List<object>));
Assert.AreNotEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
proxy.DoSomething(new List<object>(), new List<object>());
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(void),
typeof(List<object>), typeof(List<object>));
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethodInvocationTarget(), typeof(void),
typeof(List<object>), typeof(List<object>));
Assert.AreNotEqual(interceptor.Invocation.GetConcreteMethod(),
interceptor.Invocation.GetConcreteMethodInvocationTarget());
}
开发者ID:leloulight,项目名称:Core,代码行数:23,代码来源:GenericInterfaceProxyTestCase.cs
示例20: MethodInfoClosedInGenIfcNongenMethodValueTypeNoTarget
public void MethodInfoClosedInGenIfcNongenMethodValueTypeNoTarget()
{
var interceptor = new KeepDataInterceptor();
var proxy =
generator.CreateInterfaceProxyWithoutTarget<IGenInterfaceHierarchyBase<int>>(interceptor);
proxy.Get();
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(int));
proxy.Add(0);
GenericTestUtility.CheckMethodInfoIsClosed(interceptor.Invocation.GetConcreteMethod(), typeof(void), typeof(int));
}
开发者ID:leloulight,项目名称:Core,代码行数:12,代码来源:GenericInterfaceProxyTestCase.cs
注:本文中的Castle.DynamicProxy.Tests.Interceptors.KeepDataInterceptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论