本文整理汇总了C#中Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithTargetInterface方法的典型用法代码示例。如果您正苦于以下问题:C# ProxyGenerator.CreateInterfaceProxyWithTargetInterface方法的具体用法?C# ProxyGenerator.CreateInterfaceProxyWithTargetInterface怎么用?C# ProxyGenerator.CreateInterfaceProxyWithTargetInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.DynamicProxy.ProxyGenerator
的用法示例。
在下文中一共展示了ProxyGenerator.CreateInterfaceProxyWithTargetInterface方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateInterfaceProxyWithTargetInterface
public static object CreateInterfaceProxyWithTargetInterface(Type interfaceType, object concreteObject)
{
var proxyGenerator = new ProxyGenerator();
var result = proxyGenerator.CreateInterfaceProxyWithTargetInterface(interfaceType,
concreteObject,
new IInterceptor[] { new LogInterceptor(LogManager.GetLogger(concreteObject.GetType())) });
return result;
}
示例2: Main
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
// TODO: Implement Functionality Here
IUiElement rootElement =
UIAutomation.UiElement.RootElement;
DateTime startDate = System.DateTime.Now;
var proxyGenerator =
new ProxyGenerator();
var proxiedRootElement =
proxyGenerator.CreateInterfaceProxyWithTargetInterface(
typeof(IUiElement),
rootElement,
new StandardInterceptor[]{});
Console.WriteLine((System.DateTime.Now - startDate).Seconds.ToString() + "; " + (System.DateTime.Now - startDate).Ticks.ToString());
Console.WriteLine(proxiedRootElement.GetType().Name);
IUiElement proxiedtypedRootElement =
proxiedRootElement as IUiElement;
// 20140312
// Console.WriteLine(proxiedtypedRootElement.Current.Name);
// Console.WriteLine(proxiedtypedRootElement.Current.AutomationId);
// Console.WriteLine(proxiedtypedRootElement.Current.ClassName);
Console.WriteLine(proxiedtypedRootElement.GetCurrent().Name);
Console.WriteLine(proxiedtypedRootElement.GetCurrent().AutomationId);
Console.WriteLine(proxiedtypedRootElement.GetCurrent().ClassName);
var originalElement =
proxiedtypedRootElement.GetSourceElement();
// Console.WriteLine(originalElement.Current.Name);
// Console.WriteLine(originalElement.Current.AutomationId);
// Console.WriteLine(originalElement.Current.ClassName);
var arr = proxiedtypedRootElement.GetSupportedPatterns();
foreach (var ptrn in arr) {
Console.WriteLine(ptrn.ToString());
// Console.WriteLine(ptrn.SourcePattern as automationpa
}
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
示例3: defaultContainer
private static Container defaultContainer()
{
return new Container(ioc =>
{
ioc.Scan(scan =>
{
scan.TheCallingAssembly();
scan.WithDefaultConventions();
});
// It's a manual wiring up method.
var proxyGenerator = new ProxyGenerator();
ioc.For<IMyMath>().DecorateAllWith(myMath =>
proxyGenerator.CreateInterfaceProxyWithTargetInterface(myMath, new ExceptionAspect()));
});
}
示例4: GetMyClass
public IMyClass GetMyClass()
{
var proxyGenerator = new ProxyGenerator();
var myClass = proxyGenerator.CreateInterfaceProxyWithTargetInterface<IMyClass>(
new MyClass { Name = "ChavP" },
new MyInterceptorErrorAspect(),
new MyInterceptorAspect());
return myClass;
}