本文整理汇总了C#中Assembly类的典型用法代码示例。如果您正苦于以下问题:C# Assembly类的具体用法?C# Assembly怎么用?C# Assembly使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assembly类属于命名空间,在下文中一共展示了Assembly类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WithIncludesTests
public WithIncludesTests()
{
beforeAssemblyPath = Path.GetFullPath(Path.Combine(TestContext.CurrentContext.TestDirectory,@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll"));
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "3.dll");
File.Copy(beforeAssemblyPath, afterAssemblyPath, true);
var assemblyResolver = new MockAssemblyResolver
{
Directory = Path.GetDirectoryName(beforeAssemblyPath)
};
var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath,new ReaderParameters
{
AssemblyResolver = assemblyResolver
});
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
IncludeNamespaces = new List<string>{"MyNameSpace"},
LogWarning =s => warnings.Add(s)
};
weavingTask.Execute();
moduleDefinition.Write(afterAssemblyPath);
assembly = Assembly.LoadFile(afterAssemblyPath);
}
示例2: AddAssembly
public void AddAssembly(Assembly assembly)
{
if (assembly == null)
{
throw new ArgumentNullException("assembly");
}
if (!this.rawAssemblyLoaders.Contains(assembly))
{
try
{
this.rawAssemblyLoaders[assembly] = new AssemblyLoader(this, assembly, this.localAssembly == assembly);
if (this.TypesChanged != null)
{
FireEventsNoThrow(this.TypesChanged, new object[] { this, EventArgs.Empty });
}
}
catch (Exception exception)
{
this.typeLoadErrors[assembly.FullName] = exception;
if (this.TypeLoadErrorsChanged != null)
{
FireEventsNoThrow(this.TypeLoadErrorsChanged, new object[] { this, EventArgs.Empty });
}
}
}
}
示例3: IntegrationTests
public IntegrationTests()
{
beforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
#if (!DEBUG)
beforeAssemblyPath = beforeAssemblyPath.Replace("Debug", "Release");
#endif
afterAssemblyPath = beforeAssemblyPath.Replace(".dll", "2.dll");
File.Copy(beforeAssemblyPath, afterAssemblyPath, true);
var assemblyResolver = new MockAssemblyResolver
{
Directory = Path.GetDirectoryName(beforeAssemblyPath)
};
var moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath,new ReaderParameters
{
AssemblyResolver = assemblyResolver
});
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
};
weavingTask.Execute();
moduleDefinition.Write(afterAssemblyPath);
assembly = Assembly.LoadFile(afterAssemblyPath);
}
示例4: ResourceModule
internal ResourceModule(Assembly assembly, string scopeName, string location)
: base(assembly.universe)
{
this.assembly = assembly;
this.scopeName = scopeName;
this.location = location;
}
示例5: AssemblyDetailsForm_Load
private void AssemblyDetailsForm_Load(object sender, EventArgs e)
{
manager = new DBManager(RevitDocument);
//if (this.IsAdd)
//{
// lblTitle.Text = "";
//}
//else
//{
toSwap = CurrentAssembly;
// lblToSwap.Text = toSwap.AssemblyName;
loadInformation(toSwap);
//}
List<Assembly> fromModel = manager.RetrieveWallInfo();
//List<Assembly> options = null;
//if (this.IsAdd)
//options = manager.getAllAssemblies();
//options.AddRange(fromModel);
//else
// options = manager.getAssembliesByCode(toSwap.AssemblyCode);
//if (options != null)
//{
// foreach (Assembly a in options)
// cboAlternatives.Items.Add(a);
//}
}
示例6: ClassValidator
public ClassValidator(string xamlFileName, Assembly localAssembly, string rootNamespace)
{
this.xamlFileName = xamlFileName;
this.localAssembly = localAssembly;
this.eventArgs = null;
this.rootNamespace = rootNamespace;
}
示例7: Instantiate
public static void Instantiate(Assembly a, Interpreter interp)
{
Hashtable table = interp.VarTable;
try {
CodeChunk chunk = (CodeChunk)a.CreateInstance("CsiChunk");
chunk.Go(table);
// vs 0.8 we display the type and value of expressions. The variable $_ is
// always set, which is useful if you want to save the result of the last
// calculation.
if (interp.returnsValue && DumpingValue) {
object val = table["_"];
Type type = val.GetType();
string stype = type.ToString();
if (stype.StartsWith("System.")) // to simplify things a little bit...
stype = stype.Substring(7);
stype = "("+stype+")";
if (val is string) {
Print(stype,"'"+val+"'");
} else
if (val is IEnumerable) {
Print(stype);
Dumpl((IEnumerable)val);
} else
Print(stype,val);
}
} catch(Exception ex) {
Print(ex.GetType() + " was thrown: " + ex.Message);
}
}
示例8: AssemblyWeaver
static AssemblyWeaver()
{
BeforeAssemblyPath = Path.GetFullPath(@"..\..\..\AssemblyToProcess\bin\Debug\AssemblyToProcess.dll");
BeforeAssemblyPathSymbols = Path.ChangeExtension(BeforeAssemblyPath, "pdb");
#if (!DEBUG)
BeforeAssemblyPath = BeforeAssemblyPath.Replace("Debug", "Release");
BeforeAssemblyPathSymbols = BeforeAssemblyPathSymbols.Replace("Debug", "Release");
#endif
AfterAssemblyPath = BeforeAssemblyPath.Replace(".dll", "2.dll");
AfterAssemblyPathSymbols = Path.ChangeExtension(AfterAssemblyPath, "pdb");
File.Copy(BeforeAssemblyPath, AfterAssemblyPath, true);
File.Copy(BeforeAssemblyPathSymbols, AfterAssemblyPathSymbols, true);
var assemblyResolver = new MockAssemblyResolver();
var moduleDefinition = ModuleDefinition.ReadModule(AfterAssemblyPath, new ReaderParameters { ReadSymbols = true });
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
LogError = LogError,
LogInfo = LogInfo,
DefineConstants = new[] { "DEBUG" }, // Always testing the debug weaver
};
weavingTask.Execute();
moduleDefinition.Write(AfterAssemblyPath, new WriterParameters { WriteSymbols = true });
Assembly = Assembly.LoadFile(AfterAssemblyPath);
}
示例9: MainWindow
public MainWindow(ref Assembly asm)
: base(Gtk.WindowType.Toplevel)
{
this.asm = asm;
Build ();
parser = new Parser();
}
示例10: GetBuildDateTime
#pragma warning restore 0649
static DateTime GetBuildDateTime(Assembly assembly)
{
if (File.Exists(assembly.Location))
{
var buffer = new byte[Math.Max(Marshal.SizeOf(typeof(_IMAGE_FILE_HEADER)), 4)];
using (var fileStream = new FileStream(assembly.Location, FileMode.Open, FileAccess.Read))
{
fileStream.Position = 0x3C;
fileStream.Read(buffer, 0, 4);
fileStream.Position = BitConverter.ToUInt32(buffer, 0); // COFF header offset
fileStream.Read(buffer, 0, 4); // "PE\0\0"
fileStream.Read(buffer, 0, buffer.Length);
}
var pinnedBuffer = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
var coffHeader = (_IMAGE_FILE_HEADER)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(), typeof(_IMAGE_FILE_HEADER));
return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)
+ new TimeSpan(coffHeader.TimeDateStamp * TimeSpan.TicksPerSecond));
}
finally
{
pinnedBuffer.Free();
}
}
return new DateTime();
}
示例11: AssemblyWeaver
public AssemblyWeaver(string assemblyPath, List<string> referenceAssemblyPaths = null)
{
if (referenceAssemblyPaths == null)
{
referenceAssemblyPaths = new List<string>();
}
assemblyPath = FixAssemblyPath(assemblyPath);
var newAssembly = assemblyPath.Replace(".dll", "2.dll");
File.Copy(assemblyPath, newAssembly, true);
var assemblyResolver = new MockAssemblyResolver();
foreach (var referenceAssemblyPath in referenceAssemblyPaths)
{
var directoryName = Path.GetDirectoryName(referenceAssemblyPath);
assemblyResolver.AddSearchDirectory(directoryName);
}
var readerParameters = new ReaderParameters
{
AssemblyResolver = assemblyResolver
};
var moduleDefinition = ModuleDefinition.ReadModule(newAssembly, readerParameters);
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AssemblyResolver = assemblyResolver,
LogError = LogError,
ReferenceCopyLocalPaths = referenceAssemblyPaths
};
weavingTask.Execute();
moduleDefinition.Write(newAssembly);
Assembly = Assembly.LoadFrom(newAssembly);
}
示例12: run
public void run(Assembly item)
{
item
.all_types()
.where(x => !exclusion_policy.is_satisfied_by(x))
.each(x => add_registration_for(x));
}
示例13: Generate
protected override Assembly Generate()
{
var nt = Host.NameTable;
var mscorlib = Host.LoadAssembly(Host.CoreAssemblySymbolicIdentity);
var assembly = new Assembly
{
Name = nt.GetNameFor(AssemblyName),
ModuleName = nt.GetNameFor(DllName),
Kind = ModuleKind.DynamicallyLinkedLibrary,
TargetRuntimeVersion = mscorlib.TargetRuntimeVersion,
MetadataFormatMajorVersion = 2
};
assembly.AssemblyReferences.Add(mscorlib);
var rootNamespace = new RootUnitNamespace();
assembly.UnitNamespaceRoot = rootNamespace;
rootNamespace.Unit = assembly;
// define module
DefineModule(assembly, rootNamespace);
var typeA = GenerateTypeA(rootNamespace);
assembly.AllTypes.Add(typeA);
var baseType = GenericTypeInstance.GetGenericTypeInstance(typeA, new[] { Host.PlatformType.SystemString }, Host.InternFactory);
var typeB = GenerateTypeB(rootNamespace, baseType);
assembly.AllTypes.Add(typeB);
return assembly;
}
示例14: TinyMCECodeGenerator
public TinyMCECodeGenerator()
{
Context = new AssemblyContext();
Assembly = new Assembly
{
Usings = new List<string>
{
"System",
"System.Collections.Generic",
}
};
Context.Assemblies.Add(Assembly);
var asm = new Assembly
{
Classes = new List<Class>
{
new Class{Name="void"},
new Class{Name="object"},
new Class{Name="bool"},
new Class{Name="string"},
new Class{Name="Array"},
new Class{Name="int"},
new Class{Name="Function", IsDelegate=true},
}
};
Context.Assemblies.Add(asm);
ObjectClass = Context.GetClass("object");
}
示例15: GetTypeTrue
static int GetTypeTrue (Assembly a)
{
string typename = "InheritanceDemand";
Type t = a.GetType (typename, true);
Console.WriteLine ("*0* Can get type '{0}' with security.", t);
return 0;
}