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


C# TypeDef类代码示例

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


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

示例1: FindReferencesInType

		private IEnumerable<AnalyzerTreeNode> FindReferencesInType(TypeDef type)
		{
			foreach (MethodDef method in type.Methods) {
				bool found = false;
				if (!method.HasBody)
					continue;

				// ignore chained constructors
				// (since object is the root of everything, we can short circuit the test in this case)
				if (method.Name == ".ctor" &&
					(isSystemObject || analyzedType == type || TypesHierarchyHelpers.IsBaseType(analyzedType, type, false)))
					continue;

				foreach (Instruction instr in method.Body.Instructions) {
					IMethod mr = instr.Operand as IMethod;
					if (mr != null && !mr.IsField && mr.Name == ".ctor") {
						if (Helpers.IsReferencedBy(analyzedType, mr.DeclaringType)) {
							found = true;
							break;
						}
					}
				}

				Helpers.FreeMethodBody(method);

				if (found) {
					var node = new AnalyzedMethodTreeNode(method);
					node.Language = this.Language;
					yield return node;
				}
			}
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:32,代码来源:AnalyzedTypeInstantiationsTreeNode.cs

示例2: VTable

 internal VTable(TypeDef typeDef)
 {
     Type = typeDef;
     GenericArguments = null;
     Slots = new List<VTableSlot>();
     Finals = new List<VTableSlot>();
 }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:7,代码来源:VTable.cs

示例3: Initialize

		void Initialize(TypeDef type) {
			if (type.HasEvents || type.HasProperties)
				return;

			if (!type.IsValueType)
				return;
			if (type.Methods.Count != 1)
				return;
			var ctor = type.Methods[0];
			if (ctor.Name != ".ctor" || ctor.Body == null || ctor.IsStatic)
				return;
			var sig = ctor.MethodSig;
			if (sig == null || sig.Params.Count != 1)
				return;
			var ctorParam = sig.Params[0];

			if (type.Fields.Count != 1)
				return;
			var typeField = type.Fields[0];
			if (typeField.IsStatic)
				return;
			if (!new SigComparer().Equals(ctorParam, typeField.FieldType))
				return;

			typeToInfo.Add(ctor.DeclaringType, new Info(ctor.DeclaringType, typeField.FieldType));
		}
开发者ID:GodLesZ,项目名称:de4dot,代码行数:26,代码来源:LocalsRestorer.cs

示例4: FindReferencesInType

        private IEnumerable<AnalyzerTreeNode> FindReferencesInType(TypeDef type)
        {
            string name = analyzedMethod.Name;
            foreach (MethodDef method in type.Methods) {
                bool found = false;
                if (!method.HasBody)
                    continue;
                foreach (Instruction instr in method.Body.Instructions) {
                    IMethod mr = instr.Operand as IMethod;
                    if (mr != null && !mr.IsField && mr.Name == name &&
                        Helpers.IsReferencedBy(analyzedMethod.DeclaringType, mr.DeclaringType) &&
                        Decompiler.DnlibExtensions.Resolve(mr) == analyzedMethod) {
                        found = true;
                        break;
                    }
                }

                Helpers.FreeMethodBody(method);

                if (found) {
                    MethodDef codeLocation = this.Language.GetOriginalCodeLocation(method) as MethodDef;
                    if (codeLocation != null && !HasAlreadyBeenFound(codeLocation)) {
                        var node= new AnalyzedMethodTreeNode(codeLocation);
                        node.Language = this.Language;
                        yield return node;
                    }
                }
            }
        }
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:29,代码来源:AnalyzedMethodUsedByTreeNode.cs

示例5: TypeInstantiationsNode

		public TypeInstantiationsNode(TypeDef analyzedType) {
			if (analyzedType == null)
				throw new ArgumentNullException(nameof(analyzedType));

			this.analyzedType = analyzedType;
			isSystemObject = analyzedType.DefinitionAssembly.IsCorLib() && analyzedType.FullName == "System.Object";
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:7,代码来源:TypeInstantiationsNode.cs

示例6: FieldOptionsVM

        public FieldOptionsVM(FieldDefOptions options, ModuleDef ownerModule, Language language, TypeDef ownerType)
        {
            this.ownerModule = ownerModule;
            var typeSigCreatorOptions = new TypeSigCreatorOptions(ownerModule, language) {
                IsLocal = false,
                CanAddGenericTypeVar = true,
                CanAddGenericMethodVar = false,
                OwnerType = ownerType,
            };
            if (ownerType != null && ownerType.GenericParameters.Count == 0)
                typeSigCreatorOptions.CanAddGenericTypeVar = false;
            this.typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
            TypeSigCreator.PropertyChanged += typeSigCreator_PropertyChanged;

            this.customAttributesVM = new CustomAttributesVM(ownerModule, language);
            this.origOptions = options;

            this.constantVM = new ConstantVM(ownerModule, options.Constant == null ? null : options.Constant.Value, "Default value for this field");
            ConstantVM.PropertyChanged += constantVM_PropertyChanged;
            this.marshalTypeVM = new MarshalTypeVM(ownerModule, language, ownerType, null);
            MarshalTypeVM.PropertyChanged += marshalTypeVM_PropertyChanged;
            this.fieldOffset = new NullableUInt32VM(a => HasErrorUpdated());
            this.initialValue = new HexStringVM(a => HasErrorUpdated());
            this.rva = new UInt32VM(a => HasErrorUpdated());
            this.implMapVM = new ImplMapVM(ownerModule);
            ImplMapVM.PropertyChanged += implMapVM_PropertyChanged;

            this.typeSigCreator.CanAddFnPtr = false;
            ConstantVM.IsEnabled = HasDefault;
            MarshalTypeVM.IsEnabled = HasFieldMarshal;
            ImplMapVM.IsEnabled = PinvokeImpl;
            Reinitialize();
        }
开发者ID:se7ensoft,项目名称:dnSpy,代码行数:33,代码来源:FieldOptionsVM.cs

示例7: FindReferencesInType

        private IEnumerable<AnalyzerTreeNode> FindReferencesInType(TypeDef type)
        {
            if (!type.HasInterfaces)
                yield break;
            ITypeDefOrRef implementedInterfaceRef = type.Interfaces.FirstOrDefault(i => i.Interface.ResolveTypeDef() == analyzedMethod.DeclaringType).Interface;
            if (implementedInterfaceRef == null)
                yield break;

            foreach (EventDef ev in type.Events.Where(e => e.Name == analyzedEvent.Name)) {
                MethodDef accessor = ev.AddMethod ?? ev.RemoveMethod;
                if (TypesHierarchyHelpers.MatchInterfaceMethod(accessor, analyzedMethod, implementedInterfaceRef)) {
                    var node = new AnalyzedEventTreeNode(ev);
                    node.Language = this.Language;
                    yield return node;
                }
                yield break;
            }

            foreach (EventDef ev in type.Events.Where(e => e.Name.String.EndsWith(analyzedEvent.Name))) {
                MethodDef accessor = ev.AddMethod ?? ev.RemoveMethod;
                if (accessor.HasOverrides && accessor.Overrides.Any(m => Decompiler.DnlibExtensions.Resolve(m.MethodDeclaration) == analyzedMethod)) {
                    var node = new AnalyzedEventTreeNode(ev);
                    node.Language = this.Language;
                    yield return node;
                }
            }
        }
开发者ID:jorik041,项目名称:dnSpy-retired,代码行数:27,代码来源:AnalyzedInterfaceEventImplementedByTreeNode.cs

示例8: FindReferencesInType

		private IEnumerable<AnalyzerTreeNode> FindReferencesInType(TypeDef type) {
			foreach (MethodDef method in type.Methods) {
				bool found = false;
				if (!method.HasBody)
					continue;
				foreach (Instruction instr in method.Body.Instructions) {
					if (CanBeReference(instr.OpCode.Code)) {
						IField fr = instr.Operand as IField;
						if (fr != null && new SigComparer(SigComparerOptions.CompareDeclaringTypes | SigComparerOptions.PrivateScopeIsComparable).Equals(fr, analyzedField) &&
							Helpers.IsReferencedBy(analyzedField.DeclaringType, fr.DeclaringType)) {
							found = true;
							break;
						}
					}
				}

				Helpers.FreeMethodBody(method);

				if (found) {
					MethodDef codeLocation = this.Language.GetOriginalCodeLocation(method) as MethodDef;
					if (codeLocation != null && !HasAlreadyBeenFound(codeLocation)) {
						var node = new AnalyzedMethodTreeNode(codeLocation);
						node.Language = this.Language;
						yield return node;
					}
				}
			}
		}
开发者ID:arkanoid1,项目名称:dnSpy,代码行数:28,代码来源:AnalyzedFieldAccessTreeNode.cs

示例9: AnalyzedTypeExposedByTreeNode

        public AnalyzedTypeExposedByTreeNode(TypeDef analyzedType)
        {
            if (analyzedType == null)
                throw new ArgumentNullException("analyzedType");

            this.analyzedType = analyzedType;
        }
开发者ID:jorik041,项目名称:dnSpy-retired,代码行数:7,代码来源:AnalyzedTypeExposedByTreeNode.cs

示例10: CanShow

 public static bool CanShow(TypeDef type)
 {
     if (type.IsClass && !type.IsEnum) {
         return type.Methods.Where(m => m.Name == ".ctor").Any(m => !m.IsPrivate);
     }
     return false;
 }
开发者ID:jorik041,项目名称:dnSpy-retired,代码行数:7,代码来源:AnalyzedTypeInstantiationsTreeNode.cs

示例11: FindReferencesInType

		IEnumerable<IAnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
			if (analyzedType.IsEnum && type == analyzedType)
				yield break;

			if (!this.Context.Language.ShowMember(type))
				yield break;

			foreach (FieldDef field in type.Fields) {
				if (TypeIsExposedBy(field)) {
					yield return new FieldNode(field) { Context = Context };
				}
			}

			foreach (PropertyDef property in type.Properties) {
				if (TypeIsExposedBy(property)) {
					yield return new PropertyNode(property) { Context = Context };
				}
			}

			foreach (EventDef eventDef in type.Events) {
				if (TypeIsExposedBy(eventDef)) {
					yield return new EventNode(eventDef) { Context = Context };
				}
			}

			foreach (MethodDef method in type.Methods) {
				if (TypeIsExposedBy(method)) {
					yield return new MethodNode(method) { Context = Context };
				}
			}
		}
开发者ID:GreenDamTan,项目名称:dnSpy,代码行数:31,代码来源:TypeExposedByNode.cs

示例12: Inject

 /// <summary>
 ///     Injects the specified TypeDef to another module.
 /// </summary>
 /// <param name="typeDef">The source TypeDef.</param>
 /// <param name="target">The target module.</param>
 /// <returns>The injected TypeDef.</returns>
 public static TypeDef Inject(TypeDef typeDef, ModuleDef target)
 {
     var ctx = new InjectContext(typeDef.Module, target);
     PopulateContext(typeDef, ctx);
     Copy(typeDef, ctx, true);
     return (TypeDef)ctx.Map[typeDef];
 }
开发者ID:MetSystem,项目名称:ConfuserEx,代码行数:13,代码来源:InjectHelper.cs

示例13: DecompilePartialTransform

		public DecompilePartialTransform(TypeDef type, HashSet<IMemberDef> definitions, bool showDefinitions, bool addPartialKeyword, IEnumerable<ITypeDefOrRef> ifacesToRemove) {
			this.type = type;
			this.definitions = definitions;
			this.showDefinitions = showDefinitions;
			this.addPartialKeyword = addPartialKeyword;
			this.ifacesToRemove = new HashSet<ITypeDefOrRef>(ifacesToRemove, TypeEqualityComparer.Instance);
		}
开发者ID:lovebanyi,项目名称:dnSpy,代码行数:7,代码来源:DecompilePartialTransform.cs

示例14: FindReferencesInType

		IEnumerable<AnalyzerTreeNodeData> FindReferencesInType(TypeDef type) {
			string name = analyzedMethod.Name;
			foreach (MethodDef method in type.Methods) {
				if (!method.HasBody)
					continue;
				Instruction foundInstr = null;
				foreach (Instruction instr in method.Body.Instructions) {
					IMethod mr = instr.Operand as IMethod;
					if (mr != null && !mr.IsField && mr.Name == name &&
						Helpers.IsReferencedBy(analyzedMethod.DeclaringType, mr.DeclaringType) &&
						mr.ResolveMethodDef() == analyzedMethod) {
						foundInstr = instr;
						break;
					}
				}

				if (foundInstr != null) {
					MethodDef codeLocation = GetOriginalCodeLocation(method) as MethodDef;
					if (codeLocation != null && !HasAlreadyBeenFound(codeLocation)) {
						var node = new MethodNode(codeLocation) { Context = Context };
						if (codeLocation == method)
							node.SourceRef = new SourceRef(method, foundInstr.Offset, foundInstr.Operand as IMDTokenProvider);
						yield return node;
					}
				}
			}
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:27,代码来源:MethodUsedByNode.cs

示例15: DerivedTypesTreeNode

		public DerivedTypesTreeNode(AssemblyList list, TypeDef type)
		{
			this.list = list;
			this.type = type;
			this.LazyLoading = true;
			this.threading = new ThreadingSupport();
		}
开发者ID:nakijun,项目名称:dnSpy,代码行数:7,代码来源:DerivedTypesTreeNode.cs


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