本文整理汇总了C#中Assembly类的典型用法代码示例。如果您正苦于以下问题:C# Assembly类的具体用法?C# Assembly怎么用?C# Assembly使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Assembly类属于命名空间,在下文中一共展示了Assembly类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Fody,项目名称:EmptyConstructor,代码行数:31,代码来源:WithIncludesTests.cs
示例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 });
}
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:26,代码来源:TypeProvider.cs
示例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);
}
开发者ID:GeertvanHorrik,项目名称:Equals,代码行数:30,代码来源:IntegrationTests.cs
示例4: ResourceModule
internal ResourceModule(Assembly assembly, string scopeName, string location)
: base(assembly.universe)
{
this.assembly = assembly;
this.scopeName = scopeName;
this.location = location;
}
开发者ID:hindlemail,项目名称:mono,代码行数:7,代码来源:ResourceModule.cs
示例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);
//}
}
开发者ID:jrivera777,项目名称:RevitLibrary,代码行数:28,代码来源:AssemblyDetailsForm.cs
示例6: ClassValidator
public ClassValidator(string xamlFileName, Assembly localAssembly, string rootNamespace)
{
this.xamlFileName = xamlFileName;
this.localAssembly = localAssembly;
this.eventArgs = null;
this.rootNamespace = rootNamespace;
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:7,代码来源:ClassValidator.cs
示例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);
}
}
开发者ID:stevedonovan,项目名称:cs-repl,代码行数:29,代码来源:interpreter.cs
示例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);
}
开发者ID:RobertGiesecke,项目名称:Visualize,代码行数:32,代码来源:AssemblyWeaver.cs
示例9: MainWindow
public MainWindow(ref Assembly asm)
: base(Gtk.WindowType.Toplevel)
{
this.asm = asm;
Build ();
parser = new Parser();
}
开发者ID:aelinden,项目名称:OruStuff,代码行数:7,代码来源:MainWindow.cs
示例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();
}
开发者ID:lscyane,项目名称:KCBr,代码行数:31,代码来源:FormAbout.cs
示例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);
}
开发者ID:GavinOsborn,项目名称:MethodTimer,代码行数:35,代码来源:AssemblyWeaver.cs
示例12: run
public void run(Assembly item)
{
item
.all_types()
.where(x => !exclusion_policy.is_satisfied_by(x))
.each(x => add_registration_for(x));
}
开发者ID:mokhan,项目名称:mo.money,代码行数:7,代码来源:auto_wire_components_in_to_the.cs
示例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;
}
开发者ID:vestild,项目名称:nemerle,代码行数:30,代码来源:CCI.GenericBaseClassAndOverrideOfNonPublicVirtualMethod.cs
示例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");
}
开发者ID:hultqvist,项目名称:SharpKit-SDK,代码行数:28,代码来源:TinyMCECodeGenerator.cs
示例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;
}
开发者ID:nobled,项目名称:mono,代码行数:7,代码来源:reftype4.cs
示例16: GeneraDibujables
public virtual ParticulaDibujable[] GeneraDibujables(Particula[] particula,float[] color,bool aleat)
{
ArrayList result=new ArrayList();
for (int i = 0; i < particula.Length; i++)
{
if(particula[i]==null)return (ParticulaDibujable[])result.ToArray(Type.GetType("ParticulaDibujable"));
try
{
if(tempInfo==null || tempInfo.Nombre!=particula[i].GetType().Name)
{
tempInfo=pinfo.GetInfoParticulas(particula[i].GetType().Name);
}
}
catch (Exception ex) { throw new Exception("Error al Generar Particulas Dibujables"); }
assem=GestorEnsamblados.GetAssemblyByName(tempInfo.EnsambladoDibujable,tempInfo.PathDibujable);
if(aleat)
{
result.Add((ParticulaDibujable)assem.CreateInstance(tempInfo.NombreDibujable, true, BindingFlags.CreateInstance, null, new object[] {particula[i]}, null, null));
}
else
{
result.Add((ParticulaDibujable)assem.CreateInstance(tempInfo.NombreDibujable, true, BindingFlags.CreateInstance, null, new object[] {particula[i], color}, null, null));
}
}
return (ParticulaDibujable[])result.ToArray(Type.GetType("ParticulaDibujable"));
}
开发者ID:jesantana,项目名称:RSAGenerator,代码行数:28,代码来源:GestorDibujables.cs
示例17: TaskTests
public TaskTests()
{
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 moduleDefinition = ModuleDefinition.ReadModule(afterAssemblyPath);
var currentDirectory = AssemblyLocation.CurrentDirectory();
var weavingTask = new ModuleWeaver
{
ModuleDefinition = moduleDefinition,
AddinDirectoryPath = currentDirectory,
SolutionDirectoryPath = currentDirectory,
AssemblyFilePath = afterAssemblyPath,
SvnHelper = new MockSvnHelper(),
};
weavingTask.Execute();
moduleDefinition.Write(afterAssemblyPath);
weavingTask.AfterWeaving();
assembly = Assembly.LoadFile(afterAssemblyPath);
}
开发者ID:krk,项目名称:Stamp,代码行数:27,代码来源:TaskTests.cs
示例18: It_provides_a_list_of_the_dependencies_of_the_given_target_assembly
public void It_provides_a_list_of_the_dependencies_of_the_given_target_assembly()
{
const string pathToAssembly = @"F:\Projects\Spikes\DependencyVisualizer\DependencyVisualizer.Tests\bin\Debug\DependencyVisualizer.Tests.dll";
SUT = new Assembly(pathToAssembly);
Assert.Equal(6, SUT.Dependencies.Count());
}
开发者ID:pjahr,项目名称:DependencyVisualizer,代码行数:7,代码来源:AssemblyDependenciesFacts.cs
示例19: ExecuteInstanceMethod
/// <summary>
/// Execute a public method_name(args) in compiled_assembly
/// </summary>
/// <param name="compiled_assembly">compiled assembly</param>
/// <param name="methode_name">method to execute</param>
/// <param name="args">method arguments</param>
/// <returns>method execution result</returns>
public static object ExecuteInstanceMethod(Assembly compiled_assembly, string methode_name, object[] args)
{
if (compiled_assembly != null)
{
foreach (Type type in compiled_assembly.GetTypes())
{
foreach (MethodInfo method in type.GetMethods())
{
if (method.Name == methode_name)
{
if ((method != null) && (method.IsPublic))
{
object obj = Activator.CreateInstance(type, null);
return method.Invoke(obj, args);
}
else
{
throw new Exception("Cannot invoke method :" + methode_name);
}
}
}
}
}
return null;
}
开发者ID:ATouhou,项目名称:QuranCode,代码行数:32,代码来源:ScriptRunner.cs
示例20: Create
public static AttributeMap[] Create(TypeModel model, Assembly assembly)
{
#if FEAT_IKVM
const bool inherit = false;
System.Collections.Generic.IList<CustomAttributeData> all = assembly.__GetCustomAttributes(model.MapType(typeof(Attribute)), inherit);
AttributeMap[] result = new AttributeMap[all.Count];
int index = 0;
foreach (CustomAttributeData attrib in all)
{
result[index++] = new AttributeDataMap(attrib);
}
return result;
#else
#if WINRT || COREFX
Attribute[] all = System.Linq.Enumerable.ToArray(assembly.GetCustomAttributes());
#else
const bool inherit = false;
object[] all = assembly.GetCustomAttributes(inherit);
#endif
AttributeMap[] result = new AttributeMap[all.Length];
for(int i = 0 ; i < all.Length ; i++)
{
result[i] = new ReflectionAttributeMap((Attribute)all[i]);
}
return result;
#endif
}
开发者ID:GeorchW,项目名称:protobuf-net,代码行数:28,代码来源:AttributeMap.cs
注:本文中的Assembly类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论