本文整理汇总了C#中Castle.DynamicProxy.ProxyGenerator.CreateProxy方法的典型用法代码示例。如果您正苦于以下问题:C# ProxyGenerator.CreateProxy方法的具体用法?C# ProxyGenerator.CreateProxy怎么用?C# ProxyGenerator.CreateProxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Castle.DynamicProxy.ProxyGenerator
的用法示例。
在下文中一共展示了ProxyGenerator.CreateProxy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateProxy
private Object CreateProxy(Type[] interfaces, IPicoContainer container)
{
try
{
ProxyGenerator proxyGenerator = new ProxyGenerator();
object componentInstance = Delegate.GetComponentInstance(container);
return proxyGenerator.CreateProxy(interfaces, new PicoInterceptor(), componentInstance);
}
catch (ArgumentException e)
{
throw new PicoIntrospectionException("Error creating a dynamic proxy for implementation hiding", e);
}
}
示例2: NewInstance
/// <summary>
///
/// </summary>
/// <param name="dao"></param>
/// <returns></returns>
public static IDao NewInstance(Dao dao)
{
ProxyGenerator proxyGenerator = new ProxyGenerator();
IInterceptor handler = new DaoProxy(dao);
Type[] interfaces = {dao.DaoInterface, typeof(IDao)};
return (proxyGenerator.CreateProxy(interfaces, handler, dao.DaoInstance) as IDao);
}
示例3: CreateScript
protected IScript CreateScript(IList assemblies)
{
try
{
Assembly dynamicAssembly = GetCompiledAssembly(StreamReader, assemblies);
Type compiledType = getCompiledType(dynamicAssembly);
object instance = dynamicAssembly.CreateInstance(compiledType.FullName);
ProxyGenerator proxyGenerator = new ProxyGenerator();
return (IScript) proxyGenerator.CreateProxy(typeof (IScript), new ScriptInterceptor(), instance);
}
catch (ArgumentException e)
{
throw new PicoCompositionException("The script is not usable. Please specify a correct script.", e);
}
}
示例4: NameBugReportedTest
public void NameBugReportedTest()
{
ProxyGenerator proxyGenerator = new ProxyGenerator();
Castle.DynamicProxy.Test.ClassInterfaces.C.IBubu bubuC = (Castle.DynamicProxy.Test.ClassInterfaces.C.IBubu)
proxyGenerator.CreateProxy(typeof(Castle.DynamicProxy.Test.ClassInterfaces.C.IBubu), new SimpleInterceptor(), new object());
bubuC.OperationA();
Castle.DynamicProxy.Test.ClassInterfaces.D.IBubu bubuD = (Castle.DynamicProxy.Test.ClassInterfaces.D.IBubu)
proxyGenerator.CreateProxy(typeof(Castle.DynamicProxy.Test.ClassInterfaces.D.IBubu), new SimpleInterceptor(), new object());
bubuD.OperationB();
}
示例5: NewInstance
/// <summary>
/// Static constructor
/// </summary>
/// <param name="connection">The connection which been proxified.</param>
/// <param name="provider">The provider used</param>
/// <returns>A proxy</returns>
internal static IDbConnection NewInstance(IDbConnection connection, Provider provider)
{
object proxyConnection = null;
IInterceptor handler = new IDbConnectionProxy(connection, provider);
ProxyGenerator proxyGenerator = new ProxyGenerator();
proxyConnection = proxyGenerator.CreateProxy(typeof(IDbConnection), handler, connection);
return (IDbConnection) proxyConnection;
}