当前位置: 首页>>代码示例>>C#>>正文


C# IAssemblyReference类代码示例

本文整理汇总了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();
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:37,代码来源:UnitHelper.cs

示例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;
        }
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:30,代码来源:AssemblyResolver.cs

示例3: Visit

 public override void Visit(IAssemblyReference assemblyReference)
 {
     if (assemblyReference != this.module.AsAssembly)
     {
         RecordAssemblyReference(assemblyReference);
     }
 }
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:7,代码来源:ReferenceIndexer.cs

示例4: Visit

 public override void Visit(IAssemblyReference assemblyReference)
 {
     if (assemblyReference != Context.Module.GetContainingAssembly(Context))
     {
         RecordAssemblyReference(assemblyReference);
     }
 }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:7,代码来源:ReferenceIndexerBase.cs

示例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;
 }
开发者ID:Refresh06,项目名称:visualmutator,代码行数:36,代码来源:Mapper.cs

示例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;
        }
开发者ID:NuPattern,项目名称:NuPattern,代码行数:30,代码来源:AssemblyReference.cs

示例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;
        }
开发者ID:StevenVanDijk,项目名称:NuPattern,代码行数:11,代码来源:AssemblyResource.cs

示例8: AssemblyReferenceAlias

        internal AssemblyReferenceAlias(string name, IAssemblyReference assembly)
        {
            Debug.Assert(name != null);
            Debug.Assert(assembly != null);

            Name = name;
            Assembly = assembly;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:AssemblyReferenceAlias.cs

示例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);
 }
开发者ID:xornand,项目名称:cci,代码行数:12,代码来源:ResourceUseReplacer.cs

示例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;
 }
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:8,代码来源:AssemblyComparer.cs

示例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);
        }
开发者ID:dsgouda,项目名称:buildtools,代码行数:9,代码来源:AssemblyReferenceTraverser.cs

示例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&lt;T&gt;).</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;
		}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:19,代码来源:GetClassTypeReference.cs

示例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);
                }
            }
开发者ID:dsgouda,项目名称:buildtools,代码行数:12,代码来源:Implementation.cs

示例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);
                }
            }
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:14,代码来源:ImporterInfoRegistry.cs

示例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);
                }
            }
        }
开发者ID:willcraftia,项目名称:WindowsGame,代码行数:18,代码来源:ImporterInfoRegistry.cs


注:本文中的IAssemblyReference类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。