本文整理汇总了C#中ModuleScope.SaveAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleScope.SaveAssembly方法的具体用法?C# ModuleScope.SaveAssembly怎么用?C# ModuleScope.SaveAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleScope
的用法示例。
在下文中一共展示了ModuleScope.SaveAssembly方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExplicitSaveThrowsWhenSpecifiedAssemblyNotGeneratedStrongName
public void ExplicitSaveThrowsWhenSpecifiedAssemblyNotGeneratedStrongName()
{
var scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithWeakName();
Assert.Throws<InvalidOperationException>(() => scope.SaveAssembly(true));
}
示例2: SavedAssemblyHasCacheMappings
public void SavedAssemblyHasCacheMappings()
{
var scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithWeakName();
var savedPath = scope.SaveAssembly();
CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
{
var assembly = Assembly.LoadFrom((string) args[0]);
Assert.IsTrue(assembly.IsDefined(typeof (CacheMappingsAttribute), false));
},
savedPath);
File.Delete(savedPath);
}
示例3: SaveWithFlagFalseDoesntThrowsWhenMultipleAssembliesGenerated
public void SaveWithFlagFalseDoesntThrowsWhenMultipleAssembliesGenerated()
{
var scope = new ModuleScope(false);
scope.ObtainDynamicModuleWithStrongName();
scope.ObtainDynamicModuleWithWeakName();
scope.SaveAssembly();
}
示例4: ExplicitSaveWorksEvenWhenMultipleAssembliesGenerated
public void ExplicitSaveWorksEvenWhenMultipleAssembliesGenerated()
{
var scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithStrongName();
scope.ObtainDynamicModuleWithWeakName();
scope.SaveAssembly(true);
CheckSignedSavedAssembly(ModuleScope.DEFAULT_FILE_NAME);
scope.SaveAssembly(false);
CheckUnsignedSavedAssembly(ModuleScope.DEFAULT_FILE_NAME);
File.Delete(ModuleScope.DEFAULT_FILE_NAME);
}
示例5: SaveThrowsWhenNoModuleObtained
public void SaveThrowsWhenNoModuleObtained ()
{
ModuleScope scope = new ModuleScope (true);
scope.SaveAssembly ();
}
示例6: SaveThrowsWhenMultipleAssembliesGenerated
public void SaveThrowsWhenMultipleAssembliesGenerated()
{
var scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithStrongName();
scope.ObtainDynamicModuleWithWeakName();
Assert.Throws<InvalidOperationException>(() => scope.SaveAssembly());
}
示例7: SaveUnsigned
public void SaveUnsigned()
{
var scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithWeakName();
var path = ModuleScope.DEFAULT_FILE_NAME;
if (File.Exists(path))
File.Delete(path);
Assert.IsFalse(File.Exists(path));
var savedPath = scope.SaveAssembly();
Assert.AreEqual(savedPath, Path.GetFullPath(path));
CheckUnsignedSavedAssembly(path);
File.Delete(path);
}
示例8: 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);
}
示例9: ExplicitSaveThrowsWhenSpecifiedAssemblyNotGeneratedStrongName
public void ExplicitSaveThrowsWhenSpecifiedAssemblyNotGeneratedStrongName()
{
var scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithWeakName();
scope.SaveAssembly(true);
}
示例10: GenerateProxies
protected virtual GenerateProxiesResult GenerateProxies(Configuration nhibernateConfiguration, string modulePath)
{
ModuleScope moduleScope = new ModuleScope(true, ModuleScope.DEFAULT_ASSEMBLY_NAME, modulePath, ModuleScope.DEFAULT_ASSEMBLY_NAME, modulePath );
IDictionary proxies = new Hashtable();
try
{
CastleProxyFactoryFactory.ProxyFactory = new CastleProxyFactory(new DefaultProxyBuilder(moduleScope), proxies);
using (nhibernateConfiguration.BuildSessionFactory())
{
}
}
finally
{
CastleProxyFactoryFactory.ProxyFactory = null;
}
moduleScope.SaveAssembly();
moduleScope = null;
AssemblyName proxyAssemblyName = new AssemblyName(ModuleScope.DEFAULT_ASSEMBLY_NAME);
proxyAssemblyName.CodeBase = modulePath;
Assembly proxyAssembly = Assembly.Load(proxyAssemblyName);
return new GenerateProxiesResult(proxies, proxyAssembly);
}
示例11: SaveThrowsWhenMultipleAssembliesGenerated
public void SaveThrowsWhenMultipleAssembliesGenerated()
{
ModuleScope scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithStrongName();
scope.ObtainDynamicModuleWithWeakName();
scope.SaveAssembly();
}
示例12: SaveSigned
public void SaveSigned()
{
ModuleScope scope = new ModuleScope(true);
scope.ObtainDynamicModuleWithStrongName();
string path = ModuleScope.DEFAULT_FILE_NAME;
if (File.Exists(path))
File.Delete(path);
Assert.IsFalse(File.Exists(path));
string savedPath = scope.SaveAssembly();
Assert.AreEqual(savedPath, Path.GetFullPath(path));
CheckSignedSavedAssembly(path);
File.Delete(path);
}
示例13: ModuleScopeDoesntTryToDeleteFromCurrentDirectory
public void ModuleScopeDoesntTryToDeleteFromCurrentDirectory ()
{
string moduleDirectory = Path.Combine (Environment.CurrentDirectory, "GeneratedDlls");
if (Directory.Exists (moduleDirectory))
Directory.Delete (moduleDirectory, true);
string strongModulePath = Path.Combine (moduleDirectory, "Strong.dll");
string weakModulePath = Path.Combine (moduleDirectory, "Weak.dll");
Directory.CreateDirectory(moduleDirectory);
ModuleScope scope = new ModuleScope (true, "Strong", strongModulePath, "Weak", weakModulePath);
using (File.Create (Path.Combine (Environment.CurrentDirectory, "Strong.dll")))
{
scope.ObtainDynamicModuleWithStrongName ();
scope.SaveAssembly (true); // this will throw if SaveAssembly tries to delete from the current directory
}
using (File.Create (Path.Combine (Environment.CurrentDirectory, "Weak.dll")))
{
scope.ObtainDynamicModuleWithWeakName ();
scope.SaveAssembly (false); // this will throw if SaveAssembly tries to delete from the current directory
}
}
示例14: CacheMappingsHoldTypes
public void CacheMappingsHoldTypes()
{
var scope = new ModuleScope(true);
var builder = new DefaultProxyBuilder(scope);
var cp = builder.CreateClassProxyType(typeof (object), Type.EmptyTypes, ProxyGenerationOptions.Default);
var savedPath = scope.SaveAssembly();
CrossAppDomainCaller.RunInOtherAppDomain(delegate(object[] args)
{
var assembly = Assembly.LoadFrom((string) args[0]);
var attribute =
(CacheMappingsAttribute)
assembly.GetCustomAttributes(typeof (CacheMappingsAttribute), false)[0];
var entries = attribute.GetDeserializedMappings();
Assert.AreEqual(1, entries.Count);
var key = new CacheKey(typeof (object), new Type[0],
ProxyGenerationOptions.Default);
Assert.IsTrue(entries.ContainsKey(key));
Assert.AreEqual(args[1], entries[key]);
},
savedPath, cp.FullName);
File.Delete(savedPath);
}
示例15: SaveWithPath
public void SaveWithPath()
{
var strongModulePath = Path.GetTempFileName();
var weakModulePath = Path.GetTempFileName();
File.Delete(strongModulePath);
File.Delete(weakModulePath);
Assert.IsFalse(File.Exists(strongModulePath));
Assert.IsFalse(File.Exists(weakModulePath));
var scope = new ModuleScope(true,false, "Strong", strongModulePath, "Weak", weakModulePath);
scope.ObtainDynamicModuleWithStrongName();
scope.ObtainDynamicModuleWithWeakName();
scope.SaveAssembly(true);
scope.SaveAssembly(false);
Assert.IsTrue(File.Exists(strongModulePath));
Assert.IsTrue(File.Exists(weakModulePath));
File.Delete(strongModulePath);
File.Delete(weakModulePath);
}