• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cecil.AssemblyNameReference类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetAssemblyFile

 static string GetAssemblyFile(AssemblyNameReference reference, string prefix, string gac)
 {
     var gac_folder = new StringBuilder().Append(prefix).Append(reference.Version).Append("__");
     for (int i = 0; i < reference.PublicKeyToken.Length; i++)
         gac_folder.Append(reference.PublicKeyToken[i].ToString("x2"));
     return Path.Combine(Path.Combine(Path.Combine(gac, reference.Name), gac_folder.ToString()), reference.Name + ".dll");
 }
开发者ID:net-shell,项目名称:quantum-vaginer,代码行数:7,代码来源:GAC.xaml.cs


示例17: Resolve

 /// <summary>
 /// Resolve an assembly by name.
 /// </summary>
 public AssemblyDefinition Resolve(AssemblyNameReference name)
 {
     return Resolve(name, new ReaderParameters(ReadingMode.Deferred) {
         AssemblyResolver = this,
         ReadSymbols = true,
     });
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:10,代码来源:AssemblyResolver.cs


示例18: Resolve

        public virtual AssemblyDefinition Resolve(AssemblyNameReference name)
        {
            AssemblyDefinition assembly;
            string frameworkdir = Path.GetDirectoryName (typeof (object).Module.FullyQualifiedName);

            assembly = SearchDirectory (name, m_directories);
            if (assembly != null)
                return assembly;

            if (IsZero (name.Version)) {
                assembly = SearchDirectory (name, new string [] {frameworkdir});
                if (assembly != null)
                    return assembly;
            }

            #if !CF_1_0 && !CF_2_0
            if (name.Name == "mscorlib") {
                assembly = GetCorlib (name);
                if (assembly != null)
                    return assembly;
            }

            assembly = GetAssemblyInGac (name);
            if (assembly != null)
                return assembly;
            #endif

            assembly = SearchDirectory (name, new string [] {frameworkdir});
            if (assembly != null)
                return assembly;

            throw new FileNotFoundException ("Could not resolve: " + name);
        }
开发者ID:sidecut,项目名称:xaeios,代码行数:33,代码来源:BaseAssemblyResolver.cs


示例19: ReferenceMatches

		/// <summary>
		/// Determines if two assembly name references matches
		/// </summary>
		/// <param name="anref1">an assembly name reference</param>
		/// <param name="anref2">an assembly name reference to compare</param>
		/// <returns>true if matches</returns>
		public static bool ReferenceMatches(AssemblyNameReference anref1, AssemblyNameReference anref2)
		{
			// Skip Key
			return ((anref1.Name == anref2.Name) &&
			        (String.Compare(anref1.Version.ToString(2), anref2.Version.ToString(2), StringComparison.Ordinal) == 0) &&
			        (anref1.Culture == anref2.Culture));
		}
开发者ID:KitoHo,项目名称:Reflexil,代码行数:13,代码来源:CecilHelper.cs


示例20: NoBuildOrMajor

		public void NoBuildOrMajor ()
		{
			var name = new AssemblyNameReference ("Foo", new Version (0, 0));
			Assert.AreEqual ("Foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", name.FullName);

			name = new AssemblyNameReference ("Foo", new Version (0, 0, 0));
			Assert.AreEqual ("Foo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", name.FullName);
		}
开发者ID:CompilerKit,项目名称:CodeWalk,代码行数:8,代码来源:AssemblyTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cecil.CustomAttribute类代码示例发布时间:2022-05-26
下一篇:
C# Cecil.AssemblyDefinition类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap