本文整理匯總了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;
}