本文整理汇总了C#中Mono.Cecil.TypeDefinition.GetPropertiesWithoutIgnores方法的典型用法代码示例。如果您正苦于以下问题:C# TypeDefinition.GetPropertiesWithoutIgnores方法的具体用法?C# TypeDefinition.GetPropertiesWithoutIgnores怎么用?C# TypeDefinition.GetPropertiesWithoutIgnores使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.GetPropertiesWithoutIgnores方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InjectEqualsInternal
public static MethodReference InjectEqualsInternal( TypeDefinition type, TypeReference typeRef, MethodDefinition collectionEquals )
{
var methodAttributes = MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.Static;
var method = new MethodDefinition("EqualsInternal", methodAttributes, ReferenceFinder.Boolean.TypeReference);
method.CustomAttributes.MarkAsGeneratedCode();
var left = method.Parameters.Add("left", typeRef);
var right = method.Parameters.Add("right", typeRef);
var body = method.Body;
var ins = body.Instructions;
var properties = type.GetPropertiesWithoutIgnores(ignoreAttributeName);
foreach (var property in properties)
{
AddPropertyCode( type, collectionEquals, property, ins);
}
AddReturnTrue(ins);
body.OptimizeMacros();
type.Methods.Add(method);
var methodToCall = new MethodReference(method.Name, method.ReturnType, typeRef);
foreach (var parameter in method.Parameters)
{
methodToCall.Parameters.Add(parameter);
}
return methodToCall;
}
示例2: Inject
public static MethodDefinition Inject( TypeDefinition type )
{
var methodAttributes = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.Virtual;
var method = new MethodDefinition("GetHashCode", methodAttributes, ReferenceFinder.Int32.TypeReference);
method.CustomAttributes.MarkAsGeneratedCode();
var resultVariable = method.Body.Variables.Add("result", ReferenceFinder.Int32.TypeReference);
var body = method.Body;
var ins = body.Instructions;
ins.Add(Instruction.Create(OpCodes.Ldc_I4_0));
ins.Add(Instruction.Create(OpCodes.Stloc, resultVariable));
var properties = type.GetPropertiesWithoutIgnores(ignoreAttributeName);
if (properties.Length == 0)
{
AddResutInit(ins, resultVariable);
}
var isFirst = true;
foreach (var property in properties)
{
AddPropertyCode(property, isFirst, ins, resultVariable, method, type);
isFirst = false;
}
AddReturnCode(ins, resultVariable);
body.OptimizeMacros();
type.Methods.Add(method);
return method;
}
示例3: InjectEqualsInternal
public static MethodReference InjectEqualsInternal(TypeDefinition type, TypeReference typeRef, MethodDefinition collectionEquals)
{
var methodAttributes = MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.Static;
var method = new MethodDefinition("EqualsInternal", methodAttributes, ReferenceFinder.Boolean.TypeReference);
method.CustomAttributes.MarkAsGeneratedCode();
var left = method.Parameters.Add("left", typeRef);
var right = method.Parameters.Add("right", typeRef);
var body = method.Body;
body.InitLocals = true;
var ins = body.Instructions;
var properties = type.GetPropertiesWithoutIgnores(ignoreAttributeName);
foreach (var property in properties)
{
AddPropertyCode(type, collectionEquals, property, ins, left, right);
}
var methods = type.GetMethods();
var customLogic = methods
.Where(x => x.CustomAttributes.Any(y => y.AttributeType.Name == customAttribute)).ToArray();
if (customLogic.Length > 2)
{
throw new WeavingException("Only one custom method can be specified.");
}
if (customLogic.Length == 1)
{
AddCustomLogicCall(type, body, ins, customLogic);
}
AddReturnTrue(ins);
body.OptimizeMacros();
type.Methods.AddOrReplace(method);
var methodToCall = new MethodReference(method.Name, method.ReturnType, typeRef);
foreach (var parameter in method.Parameters)
{
methodToCall.Parameters.Add(parameter);
}
return methodToCall;
}