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


C# Cecil.AssemblyNameReference类代码示例

本文整理汇总了C#中Mono.Cecil.AssemblyNameReference的典型用法代码示例。如果您正苦于以下问题:C# AssemblyNameReference类的具体用法?C# AssemblyNameReference怎么用?C# AssemblyNameReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AssemblyNameReference类属于Mono.Cecil命名空间,在下文中一共展示了AssemblyNameReference类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryResolve

 public static AssemblyDefinition TryResolve(this ModuleDefinition moduleDef, AssemblyNameReference assemblyNameRef)
 {
     try {
         return moduleDef.AssemblyResolver.Resolve(assemblyNameRef);
     } catch (AssemblyResolutionException) { }
     return null;
 }
开发者ID:arcanedreams,项目名称:Piranha,代码行数:7,代码来源:ResolutionExtensions.cs

示例2: GetRenameMap

 private Dictionary<IMemberDefinition, string> GetRenameMap(AssemblyNameReference assembly)
 {
     foreach (var map in Context.DefinitionsRenameMap)
         if (map.Key.FullName == assembly.FullName)
             return map.Value;
     return null;
 }
开发者ID:Cadla,项目名称:OBFSCTR,代码行数:7,代码来源:RenameReferencesStep.cs

示例3: VisitAssemblyReference

 public override void VisitAssemblyReference(AssemblyNameReference assemblyRef, AssemblyDefinition current)
 {
     if (string.Compare(assemblyRef.Name, this.myAssembly, true) == 0)
     {
         this.Aggregator.AddMatch(current);
     }
 }
开发者ID:endjin,项目名称:Endjin.Assembly.ChangeDetection,代码行数:7,代码来源:WhoReferencesAssembly.cs

示例4: ResolveFailure

 AssemblyDefinition ResolveFailure(object sender, AssemblyNameReference reference)
 {
     string fpath = string.Empty;
     if (App.LocalDependencies.Keys.Contains(reference.FullName))
     {
         fpath = App.LocalDependencies[reference.FullName];
     }
     else
     {
         Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
         ofd.Filter = "Assembly|" + reference.Name + ".dll";
         if ((bool)ofd.ShowDialog()) fpath = ofd.FileName;
     }
     if (File.Exists(fpath))
     {
         AssemblyDefinition ad;
         try
         {
             ad = AssemblyDefinition.ReadAssembly(fpath);
             ResolvedReferences.Add(fpath);
             App.LocalDependencies.Add(reference.FullName, fpath);
             return ad;
         }
         catch (Exception)
         {
             MessageBox.Show("Unable to read assembly!");
             return ResolveFailure(sender, reference);
         }
     }
     return null;
 }
开发者ID:net-shell,项目名称:quantum-vaginer,代码行数:31,代码来源:NetDasm.cs

示例5: Parse

        public static FrameworkProfileInfo Parse(XDocument frameworkList)
        {
            var profileInfo = new FrameworkProfileInfo();
            var nameAttr = frameworkList.Root.Attribute("Name");
            profileInfo.Description = (nameAttr != null ? nameAttr.Value : null);
            profileInfo.Assemblies = new HashSet<AssemblyNameReference>(CecilEqualityComparer.Default);

            //frameworkList.Descendants("File").Select(file => AssemblyNameReference.Parse(string.Format("{0}, Version={1}, ",file.Attribute("AssemblyName").Value,)   ))
            foreach (var fileElement in frameworkList.Descendants("File")) {
                var assemblyName = fileElement.Attribute("AssemblyName").Value;

                var versionString = fileElement.Attribute("Version").Value;
                Version version = null;
                if (!Version.TryParse(versionString, out version)) {
                    Trace.WriteLine(string.Format("Warning: Couldn't parse version of the {0} assembly description.", fileElement.ToString()));
                }

                string culture = null;
                var attrib = fileElement.Attribute ("Culture");
                if (attrib != null && attrib.Value != "neutral") {
                    culture = attrib.Value;
                }

                var publicKeyTokenString = fileElement.Attribute("PublicKeyToken").Value;
                var publicKeyToken = new byte[publicKeyTokenString.Length / 2];
                for (int j = 0; j < publicKeyToken.Length; j++) {
                    publicKeyToken[j] = Byte.Parse(publicKeyTokenString.Substring(j * 2, 2), NumberStyles.HexNumber);
                }
                var assemblyNameRef = new AssemblyNameReference(assemblyName, version) { Culture = culture, PublicKeyToken = publicKeyToken };
                profileInfo.Assemblies.Add(assemblyNameRef);
            }

            return profileInfo;
        }
开发者ID:arcanedreams,项目名称:Piranha,代码行数:34,代码来源:FrameworkProfileInfo.cs

示例6: SearchDirForMatchingName

 IEnumerable<string> SearchDirForMatchingName(AssemblyNameReference assemblyNameReference)
 {
     var fileName = assemblyNameReference.Name + ".dll";
     return ReferenceDictionary.Values
         .Select(x => Path.Combine(Path.GetDirectoryName(x), fileName))
         .Where(File.Exists);
 }
开发者ID:TylerBrinkley,项目名称:Fody,代码行数:7,代码来源:AssemblyResolver.cs

示例7: Delete

        /// <summary>
        /// Remove an assembly name reference
        /// </summary>
        /// <param name="anref">Assembly name reference</param>
        public static void Delete(AssemblyNameReference anref)
        {
            IPlugin plugin = PluginFactory.GetInstance();
            ModuleDefinition moddef = null;

            foreach (IAssemblyWrapper wrapper in plugin.GetAssemblies(true))
            {
                if (wrapper.IsValid)
                {
                    if (plugin.IsAssemblyContextLoaded(wrapper.Location))
                    {
                        IAssemblyContext context = plugin.GetAssemblyContext(wrapper.Location);
                        foreach (ModuleDefinition imoddef in context.AssemblyDefinition.Modules)
                        {
                            foreach (AssemblyNameReference ianref in imoddef.AssemblyReferences)
                            {
                                if (anref == ianref)
                                {
                                    moddef = imoddef;
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            if (moddef != null)
            {
                moddef.AssemblyReferences.Remove(anref);
            }
        }
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:36,代码来源:DeleteHelper.cs

示例8: Resolve

        public override AssemblyDefinition Resolve(AssemblyNameReference name, ReaderParameters parameters)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            return Cache.GetOrCreate(name.FullName, () => base.Resolve(name, parameters));
        }
开发者ID:Caspeco,项目名称:JSIL,代码行数:7,代码来源:CILSupport.cs

示例9: GetAssembliesByReference

        public AssemblyDefinition[] GetAssembliesByReference(AssemblyNameReference referencedAssemblyName)
        {
            ArgumentUtility.CheckNotNull ("referencedAssemblyName", referencedAssemblyName);

              var trackedAssembly = GetTrackedAssembliesByReference (referencedAssemblyName);
              return trackedAssembly != null ? trackedAssembly.Select(asm => asm.AssemblyDefinition).ToArray() : null;
        }
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:7,代码来源:AssemblyTracker.cs

示例10:

 public Tuple<TypeDefinition, AssemblyDefinition> this[TypeReference typ, AssemblyNameReference assembly]
 {
     get
       {
     return typ == null ? null : this[assembly.BuildAssemblyQualifiedName (typ)];
       }
 }
开发者ID:rubicon-oss,项目名称:AssemblyTransformer,代码行数:7,代码来源:TypeDefinitionCache.cs

示例11: ShouldRemoveStrongName

        private bool ShouldRemoveStrongName(AssemblyNameReference reference)
        {
            // Strong name is not present already
            if (reference.PublicKeyToken == null || reference.PublicKeyToken.Length == 0)
            {
                return false;
            }

            // Strong name must be kept
            if (Context.StrongNameReferences.Any(r => r == reference.Name))
            {
                return false;
            }

            AssemblyDefinition assembly;

            try
            {
                // Can't find target assembly
                assembly = Context.AssemblyResolver.Resolve(reference);
            }
            catch (AssemblyResolutionException)
            {
                return false;
            }

            // Don't remove strong name to framework references
            var assemblyDir = NormalizePath(Path.GetDirectoryName(assembly.MainModule.FullyQualifiedName));
            if (Context.FrameworkPaths.Any(path => NormalizePath(path) == assemblyDir))
            {
                return false;
            }

            return true;
        }
开发者ID:Unity-Technologies,项目名称:ReferenceRewriter,代码行数:35,代码来源:RemoveStrongNamesFromAssemblyReferences.cs

示例12: WindowsRuntimeProjectionsComponent

 public WindowsRuntimeProjectionsComponent()
 {
     AssemblyNameReference reference = new AssemblyNameReference("Windows", new Version(0xff, 0xff, 0xff, 0xff)) {
         IsWindowsRuntime = true
     };
     this._windowsAssemblyReference = reference;
 }
开发者ID:CarlosHBC,项目名称:UnityDecompiled,代码行数:7,代码来源:WindowsRuntimeProjectionsComponent.cs

示例13: Resolve

        /// <summary>
        /// Attempts to resolve the assembly by searching for it in the specified directories.
        /// </summary>
        /// <param name="name">The reference name of the assembly.</param>
        /// <returns>The definition of the assembly.</returns>
        /// <exception cref="AssemblyResolutionException">The assembly wasn't found in any of the listed directories.</exception>
        public override AssemblyDefinition Resolve(AssemblyNameReference name)
        {
            try
            {
                return base.Resolve(name);
            }
            catch (AssemblyResolutionException)
            {
                Trace.WriteLine("Second-chance attempt to resolve assembly " + name.FullName + "...");
                var definitions = from dirPath in this.paths
                                  let filePath = Path.Combine(dirPath, name.Name + ".dll")
                                  where File.Exists(filePath)
                                  let definition = AssemblyDefinition.ReadAssembly(filePath)
                                  where definition.FullName == name.FullName
                                  select definition;

                var match = definitions.SingleOrDefault();
                if (match != null)
                {
                    Trace.WriteLine("Assembly " + name.FullName + " was resolved.");
                    return match;
                }

                Trace.WriteLine("Failed to resolve assembly " + name.FullName + ".");
                throw;
            }
        }
开发者ID:MainMa,项目名称:mockeverything,代码行数:33,代码来源:DefaultAssemblyResolver.cs

示例14: RewriteAssemblyReference

        private void RewriteAssemblyReference(AssemblyNameReference reference)
        {
            try
            {
                if (ShouldRewriteToWinmdReference(reference))
                {
                    Context.RewriteTarget = true;
                    reference.Version = new Version(255, 255, 255, 255);
                    reference.IsWindowsRuntime = true;
                }

                var assembly = Context.AssemblyResolver.Resolve(reference);

                if ((reference.IsWindowsRuntime != assembly.Name.IsWindowsRuntime) || (IsFrameworkAssembly(assembly) && ShouldRewriteFrameworkReference(reference, assembly)))
                {
                    Context.RewriteTarget = true;
                    reference.Version = assembly.Name.Version;
                    reference.PublicKeyToken = Copy(assembly.Name.PublicKeyToken);
                    reference.IsWindowsRuntime = assembly.Name.IsWindowsRuntime;
                }

            }
            catch (AssemblyResolutionException)
            {
            }
        }
开发者ID:Unity-Technologies,项目名称:ReferenceRewriter,代码行数:26,代码来源:RewriteAssemblyManifest.cs

示例15: GetAssembly

    public void GetAssembly(string repository, AssemblyDefinition callingAssembly, AssemblyNameReference reference, Action<Stream> callback)
    {
      if (string.IsNullOrWhiteSpace(repository)) throw new ArgumentNullException("repository");
      if (callingAssembly == null) throw new ArgumentNullException("callingAssembly");
      if (reference == null) throw new ArgumentNullException("reference");
      if (callback == null) throw new ArgumentNullException("callback");

      repository = repository.TrimEnd('/');

      var uriString = GetRepositoryAddress(callingAssembly, reference);
      var uri = new Uri(repository + uriString, UriKind.RelativeOrAbsolute);
      var request = (HttpWebRequest)WebRequestCreator.ClientHttp.Create(uri);
      request.Method = "GET";
      request.BeginGetResponse(r =>
      {
        try
        {
          var rs = (HttpWebResponse)request.EndGetResponse(r);
          var stream = rs.GetResponseStream();

          Dispatcher.BeginInvoke(() => callback(stream));
        }
        catch (WebException ex)
        {
          Debug.WriteLine(ex.Message);
          Dispatcher.BeginInvoke(() => callback(null));
        }

      }, request);
    }
开发者ID:nnieslan,项目名称:IL.View,代码行数:30,代码来源:RepositoryClient.cs


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