本文整理匯總了C#中Assembly.GetName方法的典型用法代碼示例。如果您正苦於以下問題:C# Assembly.GetName方法的具體用法?C# Assembly.GetName怎麽用?C# Assembly.GetName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Assembly
的用法示例。
在下文中一共展示了Assembly.GetName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetExtractedResources
private LowLevelList<ResourceInfo> GetExtractedResources(Assembly assembly)
{
LowLevelDictionary<String, LowLevelList<ResourceInfo>> extractedResourceDictionary = this.ExtractedResourceDictionary;
String assemblyName = assembly.GetName().FullName;
LowLevelList<ResourceInfo> resourceInfos;
if (!extractedResourceDictionary.TryGetValue(assemblyName, out resourceInfos))
return new LowLevelList<ResourceInfo>();
return resourceInfos;
}
示例2: DisplayInfo
private static void DisplayInfo(Assembly a)
{
Console.WriteLine("****** Info about Assembly ******");
Console.WriteLine("Loaded from GAC? {0}", a.GlobalAssemblyCache);
Console.WriteLine("Asm Name: {0}", a.GetName().Name);
Console.WriteLine("Asm Version: {0}", a.GetName().Version);
Console.WriteLine("Asm Culture: {0}", a.GetName().CultureInfo.DisplayName);
Console.WriteLine("\nHere are the public enums:");
// use LINQ to find public enums
Type[] types = a.GetTypes();
var publicEnums = from pe in types where pe.IsEnum &&
pe.IsPublic select pe;
foreach (var pe in publicEnums) {
Console.WriteLine(pe);
}
}
示例3: ProcessAssembly
private static void ProcessAssembly(TreeIter parent, Assembly asm)
{
string asm_name = asm.GetName ().Name;
foreach (System.Type t in asm.GetTypes ()) {
UpdateDialog ("Loading from {0}:\n{1}", asm_name, t.ToString ());
TreeIter iter = store.AppendValues (parent, t.Name, t.ToString ());
ProcessType (iter, t);
}
}
示例4: RunTests
public static void RunTests(Assembly assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
// if (_tested.Contains(assembly))
// return;
_tested.Add(assembly);
using (var sw = new StringWriter())
{
var runner = new TextUI(sw);
runner.Execute(new[] {"/nologo", assembly.FullName});
var resultText = sw.GetStringBuilder().ToString();
var assemblyName = assembly.GetName().Name;
Presenter(assemblyName, resultText);
}
}
開發者ID:DavidKimYongRak,項目名稱:Lightweight-IoC-Container-for-Unity3D,代碼行數:18,代碼來源:NUnitLiteUnityRunner.cs
示例5: AssemblyInfo
public AssemblyInfo(Assembly a)
{
if (a == null)
throw new ArgumentNullException ("a");
AssemblyName an = a.GetName ();
_name = an.ToString ();
object [] att = a.GetCustomAttributes (typeof (AssemblyTitleAttribute), false);
_title = ((att.Length > 0) ? ((AssemblyTitleAttribute) att [0]).Title : String.Empty);
att = a.GetCustomAttributes (typeof (AssemblyCopyrightAttribute), false);
_copyright = ((att.Length > 0) ? ((AssemblyCopyrightAttribute) att [0]).Copyright : String.Empty);
att = a.GetCustomAttributes (typeof (AssemblyDescriptionAttribute), false);
_description = ((att.Length > 0) ? ((AssemblyDescriptionAttribute) att [0]).Description : String.Empty);
_version = an.Version.ToString ();
}
示例6: Print
static void Print(Assembly assembly)
{
Console.WriteLine("Assembly: "+assembly.FullName+"/"+assembly.GetName());
foreach (string s in assembly.GetManifestResourceNames())
{
Console.WriteLine("Resource: "+s);
}
foreach (AssemblyName a in assembly.GetReferencedAssemblies())
{
Console.WriteLine("ReferencedAssembly: "+a.Name);
}
foreach (Module m in assembly.GetModules())
{
Console.WriteLine("Module: "+m);
foreach (Type t in m.GetTypes())
{
Console.WriteLine("Type: "+t);
foreach (MemberInfo mi in t.GetMembers())
{
Console.WriteLine(String.Format("\t{0}: {1} ", mi.MemberType, mi.Name));
}
}
}
}
示例7: ImportedAssemblyDefinition
public ImportedAssemblyDefinition (Assembly assembly, MetadataImporter importer)
{
this.assembly = assembly;
this.aname = assembly.GetName ();
this.importer = importer;
}
示例8: ListAssemblyInfo
// private void ListAssemblyInfo(Assembly assembly) {{{2
private void ListAssemblyInfo(Assembly assembly)
{
Info.AppendFormat("Assembly: {0}\n", assembly.FullName); // Assembly name
// Various statistics about the assembly
if (OAAssemblyStats || OTAll) {
Info.AppendFormat("\tLoaded from GAC: {0}\n", assembly.GlobalAssemblyCache);
Info.AppendFormat("\tAsm Name: {0}\n", assembly.GetName().Name);
Info.AppendFormat("\tAsm Version: {0}\n", assembly.GetName().Version);
Info.AppendFormat("\tAsm Culture: {0}\n", assembly.GetName().CultureInfo.DisplayName);
}
if (OAListTypes) {
Type[] types = assembly.GetTypes();
foreach (Type type in types)
ListTypeInfo(type);
}
}
示例9: MainImpl
private static void MainImpl(string[] args, Form splash)
{
try // To handle exceptions in mainform jit compilation
{
// Load latest ink version, in case the version we built against is missing.
latestInk = Assembly.LoadWithPartialName("Microsoft.Ink, PublicKeyToken=31bf3856ad364e35");
// Close the splash screen.
if (!splash.IsDisposed) splash.Close();
// No Ink? Tell the user.
if (latestInk == null)
{
string text = "Tablet PC runtime library (Microsoft.Ink.dll) not found!";
MessageBox.Show(text,Application.ProductName,MessageBoxButtons.OK,MessageBoxIcon.Stop);
Application.Exit();
return;
}
// Check to ensure that we got a version we're willing to support.
Version v = latestInk.GetName().Version;
Version vmin = new Version(1,0,2201,2); // RTM release lacks IDisposable support
Version vmax = new Version(1,7,2600,2180); // stop forward-support at Lonestar
if (v < vmin || v > vmax)
{
string text = String.Format(
"This application has not been tested with your version ({0}) \n of the Tablet PC runtime library (Microsoft.Ink.dll). \n"+
"Do you wish to continue?",
v);
DialogResult dr = MessageBox.Show(text,Application.ProductName,MessageBoxButtons.YesNo,MessageBoxIcon.Warning);
if (dr != DialogResult.Yes)
{
Application.Exit();
return;
}
}
// Hook into fusion.
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(HandleAssemblyResolve);
// Install a catch-all exception filter for UI threads, allowing the app to
// continue in some cases.
Application.ThreadException +=
new ThreadExceptionEventHandler(HandleThreadException);
// Cria a variável de armazenará as informações de conexão com o servidor
clienteEnvia = new ClienteConecta();
// Factored out, to delay JIT compilation of Ink-dependent types until
// assembly-resolve handler is firmly in place.
MainImplImpl(args);
}
catch (Exception ex)
{
HandleThreadException(null, new ThreadExceptionEventArgs(ex));
}
}
示例10: VerifyAssembly
public override void VerifyAssembly (CodeDomProvider provider, Assembly asm) {
Type genType;
// Verifying Assembly Attributes
if (Supports (provider, GeneratorSupport.AssemblyAttributes)) {
object[] attributes = asm.GetCustomAttributes (true);
bool verifiedAssemblyAttributes = VerifyAttribute (attributes, typeof (AssemblyTitleAttribute), "Title", "MyAssembly");
verifiedAssemblyAttributes &=
VerifyAttribute (attributes, typeof (AssemblyVersionAttribute), "Version", "1.0.6.2") ||
asm.GetName ().Version.Equals (new Version (1, 0, 6, 2));
if (verifiedAssemblyAttributes) {
VerifyScenario ("CheckAssemblyAttributes");
}
}
object[] customAttributes;
object[] customAttributes2;
object[] customAttributesAll;
if (FindType ("MyNamespace.MyClass", asm, out genType)) {
customAttributes = genType.GetCustomAttributes (typeof (System.ObsoleteAttribute), true);
customAttributes2 = genType.GetCustomAttributes (typeof (System.SerializableAttribute), true);
customAttributesAll = genType.GetCustomAttributes (true);
#if !WHIDBEY
if (!(provider is CSharpCodeProvider) && !(provider is VBCodeProvider) && !(provider is JScriptCodeProvider)) {
#endif
if (customAttributes.GetLength (0) == 1 &&
customAttributes2.GetLength (0) >= 1 &&
customAttributesAll.GetLength (0) >= 3) {
VerifyScenario ("CheckClassAttributes");
}
#if !WHIDBEY
}
#endif
// verify method attributes
MethodInfo methodInfo = genType.GetMethod ("MyMethod");
if (methodInfo != null &&
methodInfo.GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0 &&
methodInfo.GetCustomAttributes (typeof (System.ComponentModel.EditorAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckMyMethodAttributes");
}
// verify property attributes
PropertyInfo propertyInfo = genType.GetProperty ("MyProperty");
if (propertyInfo != null &&
propertyInfo.GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckMyPropertyAttributes");
}
// verify constructor attributes
ConstructorInfo[] constructorInfo = genType.GetConstructors ();
if (constructorInfo != null && constructorInfo.Length > 0 && !(provider is JScriptCodeProvider) &&
constructorInfo[0].GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckConstructorAttributes");
}
// verify field attributes
FieldInfo fieldInfo = genType.GetField("myField");
if (fieldInfo != null &&
fieldInfo.GetCustomAttributes (typeof (System.Xml.Serialization.XmlElementAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckMyFieldAttributes");
}
}
// verify event attributes
if (Supports (provider, GeneratorSupport.DeclareEvents) && FindType ("MyNamespace.Test", asm, out genType)) {
EventInfo eventInfo = genType.GetEvent ("MyEvent");
if (eventInfo != null &&
eventInfo.GetCustomAttributes (typeof (System.CLSCompliantAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckEventAttributes");
}
}
}
示例11: VerifyAssembly
public override void VerifyAssembly (CodeDomProvider provider, Assembly asm) {
Type genType;
// Verifying Assembly Attributes
if (Supports (provider, GeneratorSupport.AssemblyAttributes)) {
object[] attributes = asm.GetCustomAttributes (true);
bool verifiedAssemblyAttributes = VerifyAttribute (attributes, typeof (AssemblyTitleAttribute), "Title", "MyAssembly");
verifiedAssemblyAttributes &=
VerifyAttribute (attributes, typeof (AssemblyVersionAttribute), "Version", "1.0.6.2") ||
asm.GetName ().Version.Equals (new Version (1, 0, 6, 2));
if (verifiedAssemblyAttributes) {
VerifyScenario ("CheckAssemblyAttributes");
}
}
object[] customAttributes;
object[] customAttributes2;
object[] customAttributesAll;
if (FindType ("MyNamespace.MyClass", asm, out genType)) {
customAttributes = genType.GetCustomAttributes (typeof (System.ObsoleteAttribute), true);
customAttributes2 = genType.GetCustomAttributes (typeof (System.SerializableAttribute), true);
customAttributesAll = genType.GetCustomAttributes (true);
#if !WHIDBEY
// see note about class attributes
if (!(provider is CSharpCodeProvider) && !(provider is VBCodeProvider) && !(provider is JScriptCodeProvider)) {
#endif
if (customAttributes.GetLength (0) == 1 &&
customAttributes2.GetLength (0) >= 1 &&
customAttributesAll.GetLength (0) >= 3) {
VerifyScenario ("CheckClassAttributes");
}
// verify nested class attributes
if (Supports (provider, GeneratorSupport.NestedTypes)) {
Type nestedType = genType.GetNestedType ("NestedClass");
customAttributes = nestedType.GetCustomAttributes (typeof (System.SerializableAttribute), true);
if (customAttributes.GetLength (0) == 1) {
VerifyScenario ("CheckNestedClassAttributes");
}
}
#if !WHIDBEY
}
#endif
// verify method attributes
MethodInfo methodInfo = genType.GetMethod ("MyMethod");
if (methodInfo != null &&
methodInfo.GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0 &&
methodInfo.GetCustomAttributes (typeof (System.ComponentModel.EditorAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckMyMethodAttributes");
// verify parameter attributes
ParameterInfo[] paramInfo = methodInfo.GetParameters ();
if (paramInfo != null && paramInfo.Length >= 2 &&
Supports (provider, GeneratorSupport.ParameterAttributes) &&
paramInfo[0].GetCustomAttributes (typeof (System.Xml.Serialization.XmlElementAttribute), true).GetLength (0) > 0 &&
paramInfo[1].GetCustomAttributes (typeof (System.Xml.Serialization.XmlElementAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckParameterAttributes");
}
}
// verify property attributes
PropertyInfo propertyInfo = genType.GetProperty ("MyProperty");
if (propertyInfo != null &&
propertyInfo.GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckMyPropertyAttributes");
}
// verify constructor attributes
ConstructorInfo[] constructorInfo = genType.GetConstructors ();
if (constructorInfo != null && constructorInfo.Length > 0 && !(provider is JScriptCodeProvider) &&
constructorInfo[0].GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckConstructorAttributes");
}
// verify type constructor attributes if its supported
if (Supports (provider, GeneratorSupport.StaticConstructors)) {
ConstructorInfo typeInit = genType.TypeInitializer;
if (typeInit != null &&
typeInit.GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0) {
VerifyScenario ("CheckStaticConstructorAttributes");
}
}
// verify entry point method attributes if supported
if (Supports (provider, GeneratorSupport.EntryPointMethod)) {
methodInfo = asm.EntryPoint;
if (methodInfo != null &&
methodInfo.GetCustomAttributes (typeof (System.ObsoleteAttribute), true).GetLength (0) > 0)
VerifyScenario ("CheckEntryPointMethodAttributes");
}
// verify delegate attributes if supported
if (Supports (provider, GeneratorSupport.DeclareDelegates)) {
Type delType = null;
if (FindType ("MyNamespace.MyDelegate", asm, out delType) && delType != null &&
//.........這裏部分代碼省略.........
示例12: AddInternalsVisibleTo
internal override void AddInternalsVisibleTo(Assembly friend)
{
string name = friend.GetName().Name;
lock (friends)
{
if (!friends.Contains(name))
{
friends.Add(name);
((AssemblyBuilder)moduleBuilder.Assembly).SetCustomAttribute(new CustomAttributeBuilder(typeof(System.Runtime.CompilerServices.InternalsVisibleToAttribute).GetConstructor(new Type[] { typeof(string) }), new object[] { name }));
}
}
}
示例13: method_11
private string method_11(Assembly assembly_0, Type type_0)
{
try
{
if (type_0 == typeof(AssemblyCompanyAttribute))
{
AssemblyCompanyAttribute assemblyCompanyAttribute = (AssemblyCompanyAttribute)assembly_0.GetCustomAttributes(type_0, false)[0];
string result = assemblyCompanyAttribute.Company.ToString();
return result;
}
if (type_0 == typeof(AssemblyCopyrightAttribute))
{
AssemblyCopyrightAttribute assemblyCopyrightAttribute = (AssemblyCopyrightAttribute)assembly_0.GetCustomAttributes(type_0, false)[0];
string result = assemblyCopyrightAttribute.Copyright.ToString();
return result;
}
if (type_0 == typeof(AssemblyDescriptionAttribute))
{
AssemblyDescriptionAttribute assemblyDescriptionAttribute = (AssemblyDescriptionAttribute)assembly_0.GetCustomAttributes(type_0, false)[0];
string result = assemblyDescriptionAttribute.Description.ToString();
return result;
}
if (type_0 == typeof(AssemblyProductAttribute))
{
AssemblyProductAttribute assemblyProductAttribute = (AssemblyProductAttribute)assembly_0.GetCustomAttributes(type_0, false)[0];
string result = assemblyProductAttribute.Product.ToString();
return result;
}
if (type_0 == typeof(AssemblyTitleAttribute))
{
AssemblyTitleAttribute assemblyTitleAttribute = (AssemblyTitleAttribute)assembly_0.GetCustomAttributes(type_0, false)[0];
string result = assemblyTitleAttribute.Title.ToString();
return result;
}
if (type_0 == typeof(AssemblyTrademarkAttribute))
{
AssemblyTrademarkAttribute assemblyTrademarkAttribute = (AssemblyTrademarkAttribute)assembly_0.GetCustomAttributes(type_0, false)[0];
string result = assemblyTrademarkAttribute.Trademark.ToString();
return result;
}
if (type_0 == typeof(AssemblyVersionAttribute))
{
Version version = assembly_0.GetName().Version;
string result = version.ToString().Replace("v.", "").Replace("v", "");
return result;
}
if (type_0 == typeof(AssemblyName))
{
string result = assembly_0.GetName().Name;
return result;
}
}
catch
{
string result = "";
return result;
}
return "";
}
示例14: CreateMissingInAssembly
static string CreateMissingInAssembly (string baseName, Assembly assembly)
{
#if NET_2_0
return string.Format ("Could not find any resources " +
"appropriate for the specified culture or the " +
"neutral culture. Make sure \"{0}\" was correctly " +
"embedded or linked into assembly \"{1}\" at " +
"compile time, or that all the satellite assemblies " +
"required are loadable and fully signed.",
baseName + ".resources", assembly.GetName ().Name);
#else
return string.Format ("Could not find any resources " +
"appropriate for the specified culture (or the " +
"neutral culture) in the given assembly. Make " +
"sure \"{0}\" was correctly embedded or linked " +
"into assembly \"{1}\".{2}" +
"baseName: {3} locationInfo: {4} resource file " +
"name: {0} assembly: {5}", baseName + ".resources",
assembly.GetName ().Name, Environment.NewLine,
baseName, "<null>", assembly.FullName);
#endif
}
示例15: PrintAssembly
void PrintAssembly(Assembly asm)
{
// assembly name
AssemblyName[] asms = asm.GetReferencedAssemblies();
// Pre-Load the referenced assemblies first
// user can specify customerized reference through /asmpath option
foreach (AssemblyName a in asms)
{
if (TryLoadAssembly(a) == null)
{
throw new ApplicationException("Fail to Find " + a.Name);
}
}
Console.WriteLine("Loaded Assemblies");
Assembly[] asmss = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
foreach (Assembly assembly in asmss)
Console.WriteLine(assembly);
Array.Sort(asms, sc);
foreach (AssemblyName a in asms)
PrintAssemblyName(null, a, true);
PrintAssemblyName(asm, asm.GetName(), false);
// module
Module amod = asm.ManifestModule;
Module[] mods = asm.GetModules(true);
Array.Sort(mods, sc);
foreach (Module mod in mods)
{
if (!mod.Name.Equals(amod.Name))
sw.WriteLine(".module manifest " + mod.Name);
else if (!mod.IsResource())
sw.WriteLine(".module " + mod.Name);
else sw.WriteLine(".resource " + mod.Name);
PrintCustomAttributes(CustomAttributeData.GetCustomAttributes(mod));
}
// file
FileStream[] files = asm.GetFiles();
Array.Sort(files, sc);
foreach (FileStream file in files)
sw.WriteLine(".file " + Path.GetFileName(file.Name)); // TODO seems the file api has provided less than CLI such as hashcode
// .subsystem (Console or UI)We cannot get it from reflection
// .corflags ( 64, 32 or IL platforms)
PortableExecutableKinds PEKind = (PortableExecutableKinds)0;
ImageFileMachine Machine = (ImageFileMachine)0;
asm.ManifestModule.GetPEKind(out PEKind, out Machine);
sw.WriteLine(".pekind " + PEKind);
sw.WriteLine(".imageMachine " + Machine);
// .class
Type[] ts = amod.GetTypes();
Array.Sort(ts, sc);
foreach (Type t in ts)
PrintType(t, false);
// .field and .method (only the manifest module ... )
FieldInfo[] fis = amod.GetFields(bf);
Array.Sort(fis, sc);
foreach (FieldInfo fi in fis) // global fields
PrintField(fi);
MethodInfo[] mis = amod.GetMethods(bf);
Array.Sort(mis, sc);
foreach (MethodInfo mi in mis) // global methods
PrintMethod(mi);
Console.WriteLine("Loaded Assemblies");
asmss = AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies();
foreach (Assembly assembly in asmss)
Console.WriteLine(assembly);
}