本文整理汇总了C#中ModuleScope.LoadAssemblyIntoCache方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleScope.LoadAssemblyIntoCache方法的具体用法?C# ModuleScope.LoadAssemblyIntoCache怎么用?C# ModuleScope.LoadAssemblyIntoCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleScope
的用法示例。
在下文中一共展示了ModuleScope.LoadAssemblyIntoCache方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckLoadAssemblyIntoCache
private void CheckLoadAssemblyIntoCache(ProxyCreator creator)
{
var savedScope = new ModuleScope(true);
var builder = new DefaultProxyBuilder(savedScope);
var cp = creator(builder);
Assert.AreSame(cp, creator(builder));
var path = savedScope.SaveAssembly();
CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
{
var newScope = new ModuleScope(false);
var newBuilder = new DefaultProxyBuilder(newScope);
var assembly = Assembly.LoadFrom((string) args[0]);
newScope.LoadAssemblyIntoCache(assembly);
var loadedCP = assembly.GetType((string) args[1]);
Assert.AreSame(loadedCP, ((ProxyCreator) args[2])(newBuilder));
Assert.AreEqual(assembly, ((ProxyCreator) args[2])(newBuilder).Assembly);
}, path, cp.FullName, creator);
File.Delete(path);
}
示例2: LoadAssemblyIntoCache_InvalidAssembly
public void LoadAssemblyIntoCache_InvalidAssembly()
{
var newScope = new ModuleScope(false);
Assert.Throws<ArgumentException>(() =>
newScope.LoadAssemblyIntoCache(Assembly.GetExecutingAssembly())
);
}
示例3: LoadAssemblyIntoCache_DifferentGenerationOptions
public void LoadAssemblyIntoCache_DifferentGenerationOptions()
{
var savedScope = new ModuleScope(true);
var builder = new DefaultProxyBuilder(savedScope);
var options1 = new ProxyGenerationOptions();
options1.AddMixinInstance(new DateTime());
var options2 = ProxyGenerationOptions.Default;
var cp1 = builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options1);
var cp2 = builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options2);
Assert.AreNotSame(cp1, cp2);
Assert.AreSame(cp1, builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options1));
Assert.AreSame(cp2, builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, options2));
var path = savedScope.SaveAssembly();
CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
{
var newScope = new ModuleScope(false);
var newBuilder = new DefaultProxyBuilder(newScope);
var assembly = Assembly.LoadFrom((string) args[0]);
newScope.LoadAssemblyIntoCache(assembly);
var newOptions1 = new ProxyGenerationOptions();
newOptions1.AddMixinInstance(new DateTime());
var newOptions2 = ProxyGenerationOptions.Default;
var loadedCP1 = newBuilder.CreateClassProxyType(typeof (object),
Type.EmptyTypes,
newOptions1);
var loadedCP2 = newBuilder.CreateClassProxyType(typeof (object),
Type.EmptyTypes,
newOptions2);
Assert.AreNotSame(loadedCP1, loadedCP2);
Assert.AreEqual(assembly, loadedCP1.Assembly);
Assert.AreEqual(assembly, loadedCP2.Assembly);
}, path);
File.Delete(path);
}
示例4: LoadAssemblyIntoCache_InvalidAssembly
public void LoadAssemblyIntoCache_InvalidAssembly()
{
var newScope = new ModuleScope(false);
newScope.LoadAssemblyIntoCache(Assembly.GetExecutingAssembly());
}