本文整理汇总了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);
}
示例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);
}
}
}
示例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;
}
}
示例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);
}
}
}
}