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


C# LoadedAssembly类代码示例

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


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

示例1: GetFilterResult

        public override TreeViewNodeFilterResult GetFilterResult(LoadedAssembly asm, AssemblyFilterType type)
        {
            if (type == AssemblyFilterType.NonNetFile)
                return new TreeViewNodeFilterResult(FilterResult.Hidden, false);

            if (type == AssemblyFilterType.Assembly) {
                if (assembly == null || asm.AssemblyDefinition != assembly)
                    return new TreeViewNodeFilterResult(FilterResult.Hidden, false);
                return new TreeViewNodeFilterResult(null, false);
            }

            if (type == AssemblyFilterType.NetModule) {
                if (asm.AssemblyDefinition != assembly)
                    return new TreeViewNodeFilterResult(FilterResult.Hidden, false);
                if (assembly == null || assembly.ManifestModule != module) {
                    if (asm.ModuleDefinition != module)
                        return new TreeViewNodeFilterResult(FilterResult.Hidden, false);
                    return new TreeViewNodeFilterResult(null, false);
                }
                else
                    return new TreeViewNodeFilterResult(null, asm.ModuleDefinition != assembly.ManifestModule);
            }

            Debug.Fail("Invalid AssemblyFilterType value");
            return new TreeViewNodeFilterResult(FilterResult.Hidden, false);
        }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:26,代码来源:EntryPointTreeViewNodeFilter.cs

示例2: FindReferences

		IEnumerable<SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
		{
			string asmName = asm.AssemblyDefinition.Name.Name;
			string name = analyzedMethod.Name;
			string declTypeName = analyzedMethod.DeclaringType.FullName;
			foreach (TypeDefinition type in TreeTraversal.PreOrder(asm.AssemblyDefinition.MainModule.Types, t => t.NestedTypes))
			{
				ct.ThrowIfCancellationRequested();
				SharpTreeNode newNode = null;
				try {
					if (!TypesHierarchyHelpers.IsBaseType(analyzedMethod.DeclaringType, type, resolveTypeArguments: false))
						continue;

					foreach (MethodDefinition method in type.Methods) {
						ct.ThrowIfCancellationRequested();

						if (TypesHierarchyHelpers.IsBaseMethod(analyzedMethod, method)) {
							bool hidesParent = !method.IsVirtual ^ method.IsNewSlot;
							newNode = new AnalyzedMethodTreeNode(method, hidesParent ? "(hides) " : "");
						}
					}
				}
				catch (ReferenceResolvingException) {
					// ignore this type definition. maybe add a notification about such cases.
				}
				if (newNode != null)
					yield return newNode;
			}
		}
开发者ID:tris2481,项目名称:ILSpy,代码行数:29,代码来源:AnalyzerMethodOverridesTreeNode.cs

示例3: FindReferences

		IEnumerable<SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
		{
			string asmName = asm.AssemblyDefinition.Name.Name;
			string name = analyzedProperty.Name;
			string declTypeName = analyzedProperty.DeclaringType.FullName;
			foreach (TypeDefinition type in TreeTraversal.PreOrder(asm.AssemblyDefinition.MainModule.Types, t => t.NestedTypes)) {
				ct.ThrowIfCancellationRequested();

				SharpTreeNode newNode = null;
				try {
					if (!TypesHierarchyHelpers.IsBaseType(analyzedProperty.DeclaringType, type, resolveTypeArguments: false))
						continue;

					foreach (PropertyDefinition property in type.Properties) {
						ct.ThrowIfCancellationRequested();

						if (TypesHierarchyHelpers.IsBaseProperty(analyzedProperty, property)) {
							MethodDefinition anyAccessor = property.GetMethod ?? property.SetMethod;
							bool hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
							newNode = new AnalyzedPropertyTreeNode(property, hidesParent ? "(hides) " : "");
						}
					}
				}
				catch (ReferenceResolvingException) {
					// ignore this type definition.
				}
				if (newNode != null)
					yield return newNode;
			}
		}
开发者ID:ThomasZitzler,项目名称:ILSpy,代码行数:30,代码来源:AnalyzedPropertyOverridesTreeNode.cs

示例4: FindReferences

		IEnumerable<SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
		{
			string name = analyzedField.Name;
			string declTypeName = analyzedField.DeclaringType.FullName;
			foreach (TypeDefinition type in TreeTraversal.PreOrder(asm.AssemblyDefinition.MainModule.Types, t => t.NestedTypes)) {
				ct.ThrowIfCancellationRequested();
				foreach (MethodDefinition method in type.Methods) {
					ct.ThrowIfCancellationRequested();
					bool found = false;
					if (!method.HasBody)
						continue;
					foreach (Instruction instr in method.Body.Instructions) {
						if (CanBeReference(instr.OpCode.Code)) {
							FieldReference fr = instr.Operand as FieldReference;
							if (fr != null && fr.Name == name && fr.DeclaringType.FullName == declTypeName && fr.Resolve() == analyzedField) {
								found = true;
								break;
							}
						}
					}
					if (found)
						yield return new AnalyzedMethodTreeNode(method);
				}
			}
		}
开发者ID:hlesesne,项目名称:ILSpy,代码行数:25,代码来源:AnalyzedFieldAccessNode.cs

示例5: HandleModelUpdated

		public override bool HandleModelUpdated(LoadedAssembly asm)
		{
			this.LazyLoading = true;
			threading.Cancel();
			this.Children.Clear();
			return true;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:7,代码来源:AnalyzerSearchTreeNode.cs

示例6: DecompileAssembly

		public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
		{
			if (options.FullDecompilation && options.SaveAsProjectDirectory != null) {
				HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
				var files = WriteCodeFilesInProject(assembly.AssemblyDefinition, options, directories).ToList();
				files.AddRange(WriteResourceFilesInProject(assembly, options, directories));
				WriteProjectFile(new TextOutputWriter(output), files, assembly.AssemblyDefinition.MainModule);
			} else {
				base.DecompileAssembly(assembly, output, options);
				output.WriteLine();
				ModuleDefinition mainModule = assembly.AssemblyDefinition.MainModule;
				if (mainModule.EntryPoint != null) {
					output.Write("' Entry point: ");
					output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint);
					output.WriteLine();
				}
				switch (mainModule.Architecture) {
					case TargetArchitecture.I386:
						if ((mainModule.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit)
							WriteCommentLine(output, "Architecture: x86");
						else
							WriteCommentLine(output, "Architecture: AnyCPU");
						break;
					case TargetArchitecture.AMD64:
						WriteCommentLine(output, "Architecture: x64");
						break;
					case TargetArchitecture.IA64:
						WriteCommentLine(output, "Architecture: Itanium-64");
						break;
				}
				if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) {
					WriteCommentLine(output, "This assembly contains unmanaged code.");
				}
				switch (mainModule.Runtime) {
					case TargetRuntime.Net_1_0:
						WriteCommentLine(output, "Runtime: .NET 1.0");
						break;
					case TargetRuntime.Net_1_1:
						WriteCommentLine(output, "Runtime: .NET 1.1");
						break;
					case TargetRuntime.Net_2_0:
						WriteCommentLine(output, "Runtime: .NET 2.0");
						break;
					case TargetRuntime.Net_4_0:
						WriteCommentLine(output, "Runtime: .NET 4.0");
						break;
				}
				output.WriteLine();
				
				// don't automatically load additional assemblies when an assembly node is selected in the tree view
				using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) {
					AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.AssemblyDefinition.MainModule);
					codeDomBuilder.AddAssembly(assembly.AssemblyDefinition, onlyAssemblyLevel: !options.FullDecompilation);
					RunTransformsAndGenerateCode(codeDomBuilder, output, options);
				}
			}
			OnDecompilationFinished(null);
		}
开发者ID:itsff,项目名称:ILSpy,代码行数:58,代码来源:VBLanguage.cs

示例7: DecompileAssembly

		public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
		{
			if (options.FullDecompilation && options.SaveAsProjectDirectory != null) {

                //Checks if must create a solution
                if (options.CreateSolution)
                {
                    //Solution directory
                    var solutionDir = options.SaveAsProjectDirectory;

                    //List of the project names and their guid
                    List<Tuple<string, string>> projects = new List<Tuple<string, string>>();

                    //For each module
                    foreach (var module in assembly.AssemblyDefinition.Modules)
                    {
                        //Creates the project and the various files
                        var projectDir = Path.Combine(solutionDir, TextView.DecompilerTextView.CleanUpName(Path.GetFileNameWithoutExtension(module.Name)));
                        Directory.CreateDirectory(projectDir);
                        options.SaveAsProjectDirectory = projectDir;
                        HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                        var files = WriteCodeFilesInProject(module, options, directories).ToList();
                        files.AddRange(WriteResourceFilesInProject(module, options, directories));
                        using (var writer = new StreamWriter(Path.Combine(projectDir, Path.GetFileName(projectDir) + this.ProjectFileExtension), false, System.Text.Encoding.UTF8))
                            projects.Add(Tuple.Create(
                                Path.GetFileName(projectDir),
                                "{" + WriteProjectFile(writer, files, module, options).ToString().ToUpperInvariant() + "}"
                            ));
                    }

                    //Writes the solution
                    WriteSolutionFile(new TextOutputWriter(output), Enumerable.Reverse(projects));
                }
                else
                {
                    HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
                    var files = assembly.AssemblyDefinition.Modules.SelectMany(m => WriteCodeFilesInProject(m, options, directories)).ToList();
                    files.AddRange(assembly.AssemblyDefinition.Modules.SelectMany(m => WriteResourceFilesInProject(m, options, directories)));
                    WriteProjectFile(new TextOutputWriter(output), files, assembly.AssemblyDefinition.MainModule, options);
                }

			} else {
				base.DecompileAssembly(assembly, output, options);
				output.WriteLine();
                WriteCommentLine(output, "Main module:");
                WriteModuleAttributes(assembly.AssemblyDefinition.MainModule, output, options);
				output.WriteLine();
				
				// don't automatically load additional assemblies when an assembly node is selected in the tree view
				using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) {
					AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.AssemblyDefinition.MainModule);
					codeDomBuilder.AddAssembly(assembly.AssemblyDefinition, onlyAssemblyLevel: !options.FullDecompilation);
					RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.AssemblyDefinition.MainModule);
				}
			}
			OnDecompilationFinished(null);
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:57,代码来源:VBLanguage.cs

示例8: AssemblyTreeNode

		public AssemblyTreeNode(LoadedAssembly assembly)
		{
			if (assembly == null)
				throw new ArgumentNullException("assembly");

			this.assembly = assembly;

			assembly.ContinueWhenLoaded(OnAssemblyLoaded, TaskScheduler.FromCurrentSynchronizationContext());

			this.LazyLoading = true;
		}
开发者ID:keremkusmezer,项目名称:ILSpy,代码行数:11,代码来源:AssemblyTreeNode.cs

示例9: HandleModelUpdated

		public override bool HandleModelUpdated(LoadedAssembly asm)
		{
			if (this.Member.Module == null)
				return false; // remove this node
			if ((this.Member is IField || this.Member is IMethod || this.Member is PropertyDef || this.Member is EventDef) &&
				this.Member.DeclaringType == null)
				return false;
			this.Children.RemoveAll(
				delegate(SharpTreeNode n) {
					AnalyzerTreeNode an = n as AnalyzerTreeNode;
					return an == null || !an.HandleModelUpdated(asm);
				});
			return true;
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:14,代码来源:AnalyzerEntityTreeNode.cs

示例10: DecompileAssembly

		public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options)
		{
			if (options.FullDecompilation && options.SaveAsProjectDirectory != null) {
                var decompiler = new VBProjectDecompiler();
                decompiler.Decompile(this, assembly, output, options);
			} else {
				base.DecompileAssembly(assembly, output, options);
				output.WriteLine();
				ModuleDefinition mainModule = assembly.ModuleDefinition;
				if (mainModule.EntryPoint != null) {
					output.Write("' Entry point: ");
					output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint);
					output.WriteLine();
				}
				WriteCommentLine(output, "Architecture: " + CSharpLanguage.GetPlatformDisplayName(mainModule));
				if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) {
					WriteCommentLine(output, "This assembly contains unmanaged code.");
				}
				switch (mainModule.Runtime) {
					case TargetRuntime.Net_1_0:
						WriteCommentLine(output, "Runtime: .NET 1.0");
						break;
					case TargetRuntime.Net_1_1:
						WriteCommentLine(output, "Runtime: .NET 1.1");
						break;
					case TargetRuntime.Net_2_0:
						WriteCommentLine(output, "Runtime: .NET 2.0");
						break;
					case TargetRuntime.Net_4_0:
                        if (assembly.IsNet45())
                        {
                            WriteCommentLine(output, "Runtime: .NET 4.5");
                        }
                        else
                        {
                            WriteCommentLine(output, "Runtime: .NET 4.0");
                        }
						break;
				}
				output.WriteLine();
				
				// don't automatically load additional assemblies when an assembly node is selected in the tree view
				using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) {
					AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.ModuleDefinition);
					codeDomBuilder.AddAssembly(assembly.ModuleDefinition, onlyAssemblyLevel: !options.FullDecompilation);
					RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.ModuleDefinition);
				}
			}
		}
开发者ID:x-strong,项目名称:ILSpy,代码行数:49,代码来源:VBLanguage.cs

示例11: GetFilterResult

        public override TreeViewNodeFilterResult GetFilterResult(LoadedAssembly asm, AssemblyFilterType type)
        {
            VisibleMembersFlags thisFlag, visibleFlags;
            switch (type) {
            case AssemblyFilterType.Assembly:
                thisFlag = VisibleMembersFlags.AssemblyDef;
                visibleFlags = thisFlag | VisibleMembersFlags.ModuleDef |
                        VisibleMembersFlags.Namespace | VisibleMembersFlags.AnyTypeDef |
                        VisibleMembersFlags.FieldDef | VisibleMembersFlags.MethodDef |
                        VisibleMembersFlags.InstanceConstructor | VisibleMembersFlags.PropertyDef |
                        VisibleMembersFlags.EventDef | VisibleMembersFlags.AssemblyRef |
                        VisibleMembersFlags.BaseTypes | VisibleMembersFlags.DerivedTypes |
                        VisibleMembersFlags.ModuleRef | VisibleMembersFlags.ResourceList |
                        VisibleMembersFlags.MethodBody | VisibleMembersFlags.ParamDefs |
                        VisibleMembersFlags.ParamDef | VisibleMembersFlags.Locals |
                        VisibleMembersFlags.Local | VisibleMembersFlags.Resource |
                        VisibleMembersFlags.ResourceElement;
                break;

            case AssemblyFilterType.NetModule:
                thisFlag = VisibleMembersFlags.ModuleDef;
                visibleFlags = thisFlag |
                        VisibleMembersFlags.Namespace | VisibleMembersFlags.AnyTypeDef |
                        VisibleMembersFlags.FieldDef | VisibleMembersFlags.MethodDef |
                        VisibleMembersFlags.InstanceConstructor | VisibleMembersFlags.PropertyDef |
                        VisibleMembersFlags.EventDef | VisibleMembersFlags.AssemblyRef |
                        VisibleMembersFlags.BaseTypes | VisibleMembersFlags.DerivedTypes |
                        VisibleMembersFlags.ModuleRef | VisibleMembersFlags.ResourceList |
                        VisibleMembersFlags.MethodBody | VisibleMembersFlags.ParamDefs |
                        VisibleMembersFlags.ParamDef | VisibleMembersFlags.Locals |
                        VisibleMembersFlags.Local | VisibleMembersFlags.Resource |
                        VisibleMembersFlags.ResourceElement;
                break;

            case AssemblyFilterType.NonNetFile:
            default:
                thisFlag = VisibleMembersFlags.NonNetFile;
                visibleFlags = thisFlag;
                break;
            }
            bool isMatch = (flags & thisFlag) != 0;
            if ((flags & visibleFlags) == 0)
                return new TreeViewNodeFilterResult(FilterResult.Hidden, isMatch);

            if (isMatch)
                return new TreeViewNodeFilterResult(FilterResult.Match, isMatch);	// Make sure it's not hidden

            return new TreeViewNodeFilterResult(null, isMatch);
        }
开发者ID:se7ensoft,项目名称:dnSpy,代码行数:49,代码来源:FlagsTreeViewNodeFilter.cs

示例12: DecompileAssembly

		public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options, DecompileAssemblyFlags flags = DecompileAssemblyFlags.AssemblyAndModule)
		{
			if (options.FullDecompilation && options.SaveAsProjectDirectory != null) {
				HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
				var files = WriteCodeFilesInProject(assembly.ModuleDefinition, options, directories).ToList();
				files.AddRange(WriteResourceFilesInProject(assembly, options, directories));
				WriteProjectFile(new TextOutputWriter(output), files, assembly, options);
			} else {
				bool decompileAsm = (flags & DecompileAssemblyFlags.Assembly) != 0;
				bool decompileMod = (flags & DecompileAssemblyFlags.Module) != 0;
				base.DecompileAssembly(assembly, output, options, flags);
				output.WriteLine();
				ModuleDef mainModule = assembly.ModuleDefinition;
				if (decompileMod && mainModule.Types.Count > 0) {
					output.Write("' Global type: ", TextTokenType.Comment);
					output.WriteReference(IdentifierEscaper.Escape(mainModule.GlobalType.FullName), mainModule.GlobalType, TextTokenType.Comment);
					output.WriteLine();
				}
				if (decompileMod || decompileAsm)
					PrintEntryPoint(assembly, output);
				if (decompileMod) {
					WriteCommentLine(output, "Architecture: " + CSharpLanguage.GetPlatformDisplayName(mainModule));
					if (!mainModule.IsILOnly) {
						WriteCommentLine(output, "This assembly contains unmanaged code.");
					}
					string runtimeName = ICSharpCode.ILSpy.CSharpLanguage.GetRuntimeDisplayName(mainModule);
					if (runtimeName != null) {
						WriteCommentLine(output, "Runtime: " + runtimeName);
					}
				}
				if (decompileMod || decompileAsm)
					output.WriteLine();
				
				// don't automatically load additional assemblies when an assembly node is selected in the tree view
				using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) {
					AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.ModuleDefinition);
					codeDomBuilder.AddAssembly(assembly.ModuleDefinition, !options.FullDecompilation, decompileAsm, decompileMod);
					RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.ModuleDefinition);
				}
			}
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:41,代码来源:VBLanguage.cs

示例13: FindReferences

		IEnumerable<SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
		{
			string asmName = asm.AssemblyDefinition.Name.Name;
			string name = analyzedEvent.Name;
			string declTypeName = analyzedEvent.DeclaringType.FullName;
			foreach (TypeDefinition type in TreeTraversal.PreOrder(asm.AssemblyDefinition.MainModule.Types, t => t.NestedTypes)) {
				ct.ThrowIfCancellationRequested();

				if (!TypesHierarchyHelpers.IsBaseType(analyzedEvent.DeclaringType, type, resolveTypeArguments: false))
					continue;

				foreach (EventDefinition eventDef in type.Events) {
					ct.ThrowIfCancellationRequested();

					if (TypesHierarchyHelpers.IsBaseEvent(analyzedEvent, eventDef)) {
						MethodDefinition anyAccessor = eventDef.AddMethod ?? eventDef.RemoveMethod;
						bool hidesParent = !anyAccessor.IsVirtual ^ anyAccessor.IsNewSlot;
						yield return new AnalyzedEventTreeNode(eventDef, hidesParent ? "(hides) " : "");
					}
				}
			}
		}
开发者ID:tris2481,项目名称:ILSpy,代码行数:22,代码来源:AnalyzedEventOverridesTreeNode.cs

示例14: FindReferences

		IEnumerable<SharpTreeNode> FindReferences(LoadedAssembly asm, CancellationToken ct)
		{
			string asmName = asm.AssemblyDefinition.Name.Name;
			string name = analyzedMethod.Name;
			string declTypeName = analyzedMethod.DeclaringType.FullName;
			foreach (TypeDefinition type in TreeTraversal.PreOrder(asm.AssemblyDefinition.MainModule.Types, t => t.NestedTypes))
			{
				ct.ThrowIfCancellationRequested();

				if (!IsDerived(type, analyzedMethod.DeclaringType))
					continue;

				foreach (MethodDefinition method in type.Methods)
				{
					ct.ThrowIfCancellationRequested();

					if (HasCompatibleSpecification(method) && !method.IsNewSlot && DoesOverrideCorrectMethod(method))
					{
						yield return new AnalyzedMethodTreeNode(method);
					}
				}
			}
		}
开发者ID:tanujmathur,项目名称:ILSpy,代码行数:23,代码来源:AnalyzerMethodOverridesTreeNode.cs

示例15: AssemblyTreeNodeCreator

 public AssemblyTreeNodeCreator(LoadedAssembly asm)
     : this(asm, null, false)
 {
 }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:4,代码来源:AssemblyTreeNodeCreator.cs


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