本文整理汇总了C#中IAssemblyReference类的典型用法代码示例。如果您正苦于以下问题:C# IAssemblyReference类的具体用法?C# IAssemblyReference怎么用?C# IAssemblyReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAssemblyReference类属于命名空间,在下文中一共展示了IAssemblyReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StrongName
/// <summary>
/// Computes the string representing the strong name of the given assembly reference.
/// </summary>
public static string StrongName(IAssemblyReference assemblyReference)
{
StringBuilder sb = new StringBuilder();
sb.Append(assemblyReference.Name);
sb.AppendFormat(CultureInfo.InvariantCulture, ", Version={0}.{1}.{2}.{3}", assemblyReference.Version.Major, assemblyReference.Version.Minor, assemblyReference.Version.Build, assemblyReference.Version.Revision);
if (assemblyReference.Culture != null && assemblyReference.Culture.Length > 0)
{
sb.AppendFormat(CultureInfo.InvariantCulture, ", Culture={0}", assemblyReference.Culture);
}
else
{
sb.Append(", Culture=neutral");
}
sb.Append(", PublicKeyToken=");
if (IteratorHelper.EnumerableIsNotEmpty(assemblyReference.PublicKeyToken))
{
foreach (byte b in assemblyReference.PublicKeyToken)
{
sb.Append(b.ToString("x2"));
}
}
else
{
sb.Append("null");
}
if (assemblyReference.IsRetargetable)
{
sb.Append(", Retargetable=Yes");
}
return sb.ToString();
}
示例2: Resolve
public IAssembly Resolve(IAssemblyReference value, string localPath)
{
foreach (IAssembly ia in _assemblyManager.Assemblies)
{
if (ia.CompareTo(value) == 0)
return ia;
}
string assemblyString = value.ToString();
Assembly assembly = null;
try
{
assembly = AssemblyUtils.ResolveAssemblyFile(assemblyString, localPath);
if (assembly == null)
{
assembly = AssemblyUtils.LoadAssembly(assemblyString);
}
}
catch
{
}
if (assembly != null)
{
IAssembly ia = _assemblyManager.LoadFile(assembly.Location);
return ia;
}
return null;
}
示例3: Visit
public override void Visit(IAssemblyReference assemblyReference)
{
if (assemblyReference != this.module.AsAssembly)
{
RecordAssemblyReference(assemblyReference);
}
}
示例4: Visit
public override void Visit(IAssemblyReference assemblyReference)
{
if (assemblyReference != Context.Module.GetContainingAssembly(Context))
{
RecordAssemblyReference(assemblyReference);
}
}
示例5: GetAssembly
/// <summary>
/// Returns a "live" System.Reflection.Assembly instance that provides reflective access to the referenced assembly.
/// If the assembly cannot be found or cannot be loaded, the result is null.
/// </summary>
public Assembly/*?*/ GetAssembly(IAssemblyReference/*?*/ assemblyReference) {
if (assemblyReference == null) return null;
var ident = assemblyReference.AssemblyIdentity;
Assembly result = null;
if (!this.assemblyMap.TryGetValue(ident, out result)) {
var name = new System.Reflection.AssemblyName();
if (!String.IsNullOrEmpty(ident.Location))
name.CodeBase = new Uri(ident.Location).ToString();
name.CultureInfo = new System.Globalization.CultureInfo(ident.Culture);
name.Name = ident.Name.Value;
name.SetPublicKeyToken(new List<byte>(ident.PublicKeyToken).ToArray());
name.Version = ident.Version;
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var loadedAssem in loadedAssemblies) {
if (System.Reflection.AssemblyName.ReferenceMatchesDefinition(name, loadedAssem.GetName())) {
result = loadedAssem;
break;
}
}
if (result == null) {
try {
result = Assembly.Load(name);
} catch (System.UriFormatException) {
} catch (System.IO.FileNotFoundException) {
} catch (System.IO.FileLoadException) {
} catch (System.BadImageFormatException) {
}
this.assemblyMap.Add(ident, result);
}
}
return result;
}
示例6: GetAssemblyResourceNames
private static IEnumerable<IAssemblyResource> GetAssemblyResourceNames(IAssemblyReference assemblyReference)
{
Guard.NotNull(() => assemblyReference, assemblyReference);
var resources = new List<IAssemblyResource>();
if (!String.IsNullOrEmpty(assemblyReference.Path))
{
if (File.Exists(assemblyReference.Path))
{
try
{
var assembly = Assembly.ReflectionOnlyLoadFrom(assemblyReference.Path);
if (assembly != null)
{
// .NET resources
resources.AddRange(LoadResources(assembly, @".resources").Select(r => new AssemblyResource(assemblyReference, r)));
// XAML resources
resources.AddRange(LoadResources(assembly, @".g.resources").Select(r => new AssemblyResource(assemblyReference, r)));
}
}
catch (Exception)
{
// Ignore the exception
}
}
}
return resources;
}
示例7: AssemblyResource
/// <summary>
/// Creates a new instance of the <see cref="AssemblyResource"/> class.
/// </summary>
public AssemblyResource(IAssemblyReference assembly, string name)
{
Guard.NotNull(() => assembly, assembly);
Guard.NotNullOrEmpty(() => name, name);
this.assembly = assembly;
this.name = name;
}
示例8: AssemblyReferenceAlias
internal AssemblyReferenceAlias(string name, IAssemblyReference assembly)
{
Debug.Assert(name != null);
Debug.Assert(assembly != null);
Name = name;
Assembly = assembly;
}
示例9: CreateTypeReference
/// <summary>
/// Creates a type reference anchored in the given assembly reference and whose names are relative to the given host.
/// When the type name has periods in it, a structured reference with nested namespaces is created.
/// </summary>
private static INamespaceTypeReference CreateTypeReference(IMetadataHost host, IAssemblyReference assemblyReference, string typeName)
{
IUnitNamespaceReference ns = new Immutable.RootUnitNamespaceReference(assemblyReference);
string[] names = typeName.Split('.');
for (int i = 0, n = names.Length - 1; i < n; i++)
ns = new Immutable.NestedUnitNamespaceReference(ns, host.NameTable.GetNameFor(names[i]));
return new Immutable.NamespaceTypeReference(host, ns, host.NameTable.GetNameFor(names[names.Length - 1]), 0, false, false, true, PrimitiveTypeCode.NotPrimitive);
}
示例10: Equals
public bool Equals(IAssemblyReference assemblyReference1, IAssemblyReference assemblyReference2)
{
return assemblyReference1 != null &&
assemblyReference2 != null &&
assemblyReference1.Name != null &&
assemblyReference1.Name == assemblyReference2.Name &&
assemblyReference1.Culture == assemblyReference2.Culture;
}
示例11: AddAssemblyReference
protected void AddAssemblyReference(IAssemblyReference assembly)
{
if (assembly == null)
return;
AssemblyIdentity id = assembly.AssemblyIdentity;
if (!UsedAssemblyReferences.Contains(id)) // Only checking for contains for so can easily see new additions with a breakpoint in the debugger.
UsedAssemblyReferences.Add(id);
}
示例12: GetClassTypeReference
/// <summary>
/// Creates a new GetClassTypeReference that searches a top-level type in the specified assembly.
/// </summary>
/// <param name="assembly">A reference to the assembly containing this type.
/// If this parameter is null, the GetClassTypeReference will search in all assemblies belonging to the ICompilation.</param>
/// <param name="nameSpace">The namespace name containing the type, e.g. "System.Collections.Generic".</param>
/// <param name="name">The name of the type, e.g. "List".</param>
/// <param name="typeParameterCount">The number of type parameters, (e.g. 1 for List<T>).</param>
public GetClassTypeReference(IAssemblyReference assembly, string nameSpace, string name, int typeParameterCount)
{
if (nameSpace == null)
throw new ArgumentNullException("nameSpace");
if (name == null)
throw new ArgumentNullException("name");
this.assembly = assembly;
this.nameSpace = nameSpace;
this.name = name;
this.typeParameterCount = typeParameterCount;
}
示例13: AddAssemblyReference
public void AddAssemblyReference(IAssemblyReference assembly)
{
if (null == assembly)
return;
IAssembly assemblyDef = assembly.ResolvedAssembly;
if (!AssembliesClosure.ContainsKey(assemblyDef.Name.Value))
{
AssembliesClosure.Add(assemblyDef.Name.Value, assemblyDef);
_workList.Enqueue(assemblyDef);
}
}
示例14: Unregister
public void Unregister(IAssemblyReference assemblyReference)
{
if (assemblyReference == null) throw new ArgumentNullException("assemblyReference");
var assembly = assemblyReference.LoadAssembly();
foreach (var type in assembly.GetTypes())
{
if (IsImporter(type))
{
importerInfos.Remove(type.Name);
Tracer.TraceSource.TraceInformation("Unregistered ContentImporter '{0}'.", type.Name);
}
}
}
示例15: Register
public void Register(IAssemblyReference assemblyReference)
{
if (assemblyReference == null) throw new ArgumentNullException("assemblyReference");
var assembly = assemblyReference.LoadAssembly();
Tracer.TraceSource.TraceInformation("Parsing ContentImporters from assembly '{0}'.", assembly.FullName);
foreach (var type in assembly.GetTypes())
{
if (IsImporter(type))
{
var attribute = GetContentImporterAttribute(type);
importerInfos[type.Name] = new AssemblyReferenceImporterInfo(type.FullName, attribute, assemblyReference);
Tracer.TraceSource.TraceInformation("Registered ContentImporter '{0}'.", type.Name);
}
}
}