本文整理汇总了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");
}
示例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");
}
示例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"));
}
示例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();
}
示例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();
}
示例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");
}
示例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");
}
示例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");
}
示例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();
}
示例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");
}
示例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");
}
示例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");
}
示例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();
}
示例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");
}
示例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");
}