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


C# TypeDef.FindField方法代码示例

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


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

示例1: GetField

		public static FieldDef GetField(TypeDef type, IField fieldRef) {
			if (type == null || fieldRef == null)
				return null;
			if (fieldRef is FieldDef)
				return (FieldDef)fieldRef;
			return type.FindField(fieldRef.Name, fieldRef.FieldSig);
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:7,代码来源:DotNetUtils.cs

示例2: ProcessConverter

        private void ProcessConverter(PropertyWithConverterRecord rec, TypeDef type)
        {
            TypeDef converter = ResolveType(rec.ConverterTypeId);

            if (converter.FullName == "System.ComponentModel.EnumConverter") {
                if (type != null && context.Modules.Contains((ModuleDefMD)type.Module)) {
                    FieldDef enumField = type.FindField(rec.Value);
                    if (enumField != null)
                        service.AddReference(enumField, new BAMLEnumReference(enumField, rec));
                }
            }
            else if (converter.FullName == "System.Windows.Input.CommandConverter") {
                string cmd = rec.Value.Trim();
                int index = cmd.IndexOf('.');
                if (index != -1) {
                    string typeName = cmd.Substring(0, index);
                    string prefix;
                    TypeSig sig = ResolveType(typeName, out prefix);
                    if (sig != null) {
                        string cmdName = cmd.Substring(index + 1);

                        TypeDef typeDef = sig.ToBasicTypeDefOrRef().ResolveTypeDefThrow();
                        if (context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
                            PropertyDef property = typeDef.FindProperty(cmdName);
                            if (property != null) {
                                var reference = new BAMLConverterMemberReference(xmlnsCtx, sig, property, rec);
                                AddTypeSigReference(sig, reference);
                                service.ReduceRenameMode(property, RenameMode.Letters);
                                service.AddReference(property, reference);
                            }
                            FieldDef field = typeDef.FindField(cmdName);
                            if (field != null) {
                                var reference = new BAMLConverterMemberReference(xmlnsCtx, sig, field, rec);
                                AddTypeSigReference(sig, reference);
                                service.ReduceRenameMode(field, RenameMode.Letters);
                                service.AddReference(field, reference);
                            }
                            if (property == null && field == null)
                                context.Logger.WarnFormat("Could not resolve command '{0}' in '{1}'.", cmd, bamlName);
                        }
                    }
                }
            }
            else if (converter.FullName == "System.Windows.Markup.DependencyPropertyConverter") {
                // Umm... Again nothing to do, DP already won't be renamed.
            }
            else if (converter.FullName == "System.Windows.PropertyPathConverter") {
                AnalyzePropertyPath(rec.Value);
            }
            else if (converter.FullName == "System.Windows.Markup.RoutedEventConverter") {
                throw new NotImplementedException();
            }
            else if (converter.FullName == "System.Windows.Markup.TypeTypeConverter") {
                string prefix;
                TypeSig sig = ResolveType(rec.Value.Trim(), out prefix);
                if (sig != null && context.Modules.Contains((ModuleDefMD)sig.ToBasicTypeDefOrRef().ResolveTypeDefThrow().Module)) {
                    var reference = new BAMLConverterTypeReference(xmlnsCtx, sig, rec);
                    AddTypeSigReference(sig, reference);
                }
            }
        }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:61,代码来源:BAMLAnalyzer.cs

示例3: CheckVersion

 void CheckVersion(TypeDef attr)
 {
     var versionField = attr.FindField("Version");
     if (versionField != null && versionField.IsLiteral && versionField.Constant != null && versionField.Constant.Value is string) {
         var val = Regex.Match((string)versionField.Constant.Value, @"^(\d+\.\d+\.\d+\.\d+)$");
         if (val.Groups.Count < 2)
             return;
         obfuscatorName = string.Format("{0} {1}", DeobfuscatorInfo.THE_NAME, val.Groups[1].ToString());
         return;
     }
 }
开发者ID:kakkerlakgly,项目名称:de4dot,代码行数:11,代码来源:Deobfuscator.cs

示例4: ProcessConverter

        void ProcessConverter(PropertyWithConverterRecord rec, TypeDef type)
        {
            TypeDef converter = ResolveType(rec.ConverterTypeId);

            if (converter.FullName == "System.ComponentModel.EnumConverter") {
                if (type != null && context.Modules.Contains((ModuleDefMD)type.Module)) {
                    FieldDef enumField = type.FindField(rec.Value);
                    if (enumField != null)
                        service.AddReference(enumField, new BAMLEnumReference(enumField, rec));
                }
            }
            else if (converter.FullName == "System.Windows.Input.CommandConverter") {
                string cmd = rec.Value.Trim();
                int index = cmd.IndexOf('.');
                if (index != -1) {
                    string typeName = cmd.Substring(0, index);
                    string prefix;
                    TypeSig sig = ResolveType(typeName, out prefix);
                    if (sig != null) {
                        string cmdName = cmd.Substring(index + 1);

                        TypeDef typeDef = sig.ToBasicTypeDefOrRef().ResolveTypeDefThrow();
                        if (context.Modules.Contains((ModuleDefMD)typeDef.Module)) {
                            PropertyDef property = typeDef.FindProperty(cmdName);
                            if (property != null) {
                                var reference = new BAMLConverterMemberReference(xmlnsCtx, sig, property, rec);
                                AddTypeSigReference(sig, reference);
                                service.ReduceRenameMode(property, RenameMode.Letters);
                                service.AddReference(property, reference);
                            }
                            FieldDef field = typeDef.FindField(cmdName);
                            if (field != null) {
                                var reference = new BAMLConverterMemberReference(xmlnsCtx, sig, field, rec);
                                AddTypeSigReference(sig, reference);
                                service.ReduceRenameMode(field, RenameMode.Letters);
                                service.AddReference(field, reference);
                            }
                            if (property == null && field == null)
                                context.Logger.WarnFormat("Could not resolve command '{0}' in '{1}'.", cmd, CurrentBAMLName);
                        }
                    }
                }
            }
            else if (converter.FullName == "System.Windows.Markup.DependencyPropertyConverter") {
                // Umm... Again nothing to do, DP already won't be renamed.
            }
            else if (converter.FullName == "System.Windows.PropertyPathConverter") {
                AnalyzePropertyPath(rec.Value);
            }
            else if (converter.FullName == "System.Windows.Markup.RoutedEventConverter") {
                ;
            }
            else if (converter.FullName == "System.Windows.Markup.TypeTypeConverter") {
                string prefix;
                TypeSig sig = ResolveType(rec.Value.Trim(), out prefix);
                if (sig != null && context.Modules.Contains((ModuleDefMD)sig.ToBasicTypeDefOrRef().ResolveTypeDefThrow().Module)) {
                    var reference = new BAMLConverterTypeReference(xmlnsCtx, sig, rec);
                    AddTypeSigReference(sig, reference);
                }
            }

            var attrInfo = ResolveAttribute(rec.AttributeId);
            string attrName = null;
            if (attrInfo.Item1 != null)
                attrName = attrInfo.Item1.Name;
            else if (attrInfo.Item2 != null)
                attrName = attrInfo.Item2.Name;

            if (attrName == "DisplayMemberPath") {
                AnalyzePropertyPath(rec.Value);
            }
            else if (attrName == "Source") {
                string declType = null;
                if (attrInfo.Item1 is IMemberDef)
                    declType = ((IMemberDef)attrInfo.Item1).DeclaringType.FullName;
                else if (attrInfo.Item2 != null)
                    declType = ResolveType(attrInfo.Item2.OwnerTypeId).FullName;
                if (declType == "System.Windows.ResourceDictionary") {
                    var src = rec.Value.ToUpperInvariant();
                    if (src.EndsWith(".BAML") || src.EndsWith(".XAML")) {
                        var match = WPFAnalyzer.UriPattern.Match(src);
                        if (match.Success)
                            src = match.Groups[1].Value;

                        if (!src.Contains("//")) {
                            var rel = new Uri(new Uri(packScheme + "application:,,,/" + CurrentBAMLName), src);
                            src = rel.LocalPath;
                        }
                        var reference = new BAMLPropertyReference(rec);
                        src = src.TrimStart('/');
                        var baml = src.Substring(0, src.Length - 5) + ".BAML";
                        var xaml = src.Substring(0, src.Length - 5) + ".XAML";
                        var bamlRefs = service.FindRenamer<WPFAnalyzer>().bamlRefs;
                        bamlRefs.AddListEntry(baml, reference);
                        bamlRefs.AddListEntry(xaml, reference);
                    }
                }
            }
        }
开发者ID:cybercircuits,项目名称:ConfuserEx,代码行数:99,代码来源:BAMLAnalyzer.cs


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