本文整理汇总了C#中TypeDefinition.IsCompilerGenerated方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.IsCompilerGenerated方法的具体用法?C# TypeDefinition.IsCompilerGenerated怎么用?C# TypeDefinition.IsCompilerGenerated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.IsCompilerGenerated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InjectField
void InjectField(TypeDefinition type, FieldDefinition fieldDefinition)
{
var staticConstructor = type.GetStaticConstructor();
var instructions = staticConstructor.Body.Instructions;
if (type.HasGenericParameters)
{
instructions.Insert(0, Instruction.Create(OpCodes.Call, buildLoggerGenericMethod));
instructions.Insert(1, Instruction.Create(OpCodes.Stsfld, fieldDefinition.GetGeneric()));
}
else
{
var logName = type.FullName;
if (type.IsCompilerGenerated() && type.IsNested)
{
logName = type.DeclaringType.FullName;
}
instructions.Insert(0, Instruction.Create(OpCodes.Ldstr, logName));
instructions.Insert(1, Instruction.Create(OpCodes.Call, buildLoggerMethod));
instructions.Insert(2, Instruction.Create(OpCodes.Stsfld, fieldDefinition));
}
type.Fields.Add(fieldDefinition);
}
示例2: ProcessType
private void ProcessType(TypeDefinition type)
{
if (type.IsCompilerGenerated() && type.IsIAsyncStateMachine())
{
return;
}
foreach (var method in type.MethodsWithBody())
{
try
{
ProcessBody(method);
}
catch (Exception ex)
{
LogTo.Error(ex, "Error processing method '{0}'", method);
}
}
foreach (var property in type.ConcreteProperties())
{
if (property.GetMethod != null)
{
try
{
ProcessBody(property.GetMethod);
}
catch (Exception ex)
{
LogTo.Error(ex, "Error processing property getter '{0}'", property);
}
}
if (property.SetMethod != null)
{
try
{
ProcessBody(property.SetMethod);
}
catch (Exception ex)
{
LogTo.Error(ex, "Error processing property setter '{0}'", property);
}
}
}
}