本文整理汇总了C#中Mono.Cecil.PropertyDefinition.GetGetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyDefinition.GetGetMethod方法的具体用法?C# PropertyDefinition.GetGetMethod怎么用?C# PropertyDefinition.GetGetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Cecil.PropertyDefinition
的用法示例。
在下文中一共展示了PropertyDefinition.GetGetMethod方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSimpleValueCheck
static void AddSimpleValueCheck(Collection<Instruction> c, PropertyDefinition property, TypeDefinition type, ParameterDefinition left, ParameterDefinition right)
{
var getMethod = property.GetGetMethod(type);
var getMethodImported = ReferenceFinder.ImportCustom(getMethod);
c.Add(Instruction.Create(type.GetLdArgForType(), left));
c.Add(Instruction.Create(getMethodImported.GetCallForMethod(), getMethodImported));
c.Add(Instruction.Create(type.GetLdArgForType(), right));
c.Add(Instruction.Create(getMethodImported.GetCallForMethod(), getMethodImported));
c.Add(Instruction.Create(OpCodes.Ceq));
}
示例2: AddCollectionEquals
static void AddCollectionEquals(TypeDefinition type, MethodDefinition collectionEquals, PropertyDefinition property, TypeDefinition propType, Collection<Instruction> e, ParameterDefinition left, ParameterDefinition right)
{
e.If(
cf =>
{
cf.Add(Instruction.Create(type.GetLdArgForType(), right));
cf.Add(Instruction.Create(OpCodes.Ldnull));
cf.Add(Instruction.Create(OpCodes.Ceq));
},
t => t.Add(Instruction.Create(OpCodes.Ldc_I4_0)),
es =>
{
var getMethod = property.GetGetMethod(type);
var getMethodImported = ReferenceFinder.ImportCustom(getMethod);
es.Add(Instruction.Create(type.GetLdArgForType(), left));
es.Add(Instruction.Create(getMethodImported.GetCallForMethod(), getMethodImported));
if (propType.IsValueType)
{
es.Add(Instruction.Create(OpCodes.Box, propType));
}
es.Add(Instruction.Create(type.GetLdArgForType(), right));
es.Add(Instruction.Create(getMethodImported.GetCallForMethod(), getMethodImported));
if (propType.IsValueType)
{
es.Add(Instruction.Create(OpCodes.Box, propType));
}
es.Add(Instruction.Create(OpCodes.Call, collectionEquals));
});
}
示例3: AddNormalCheck
static void AddNormalCheck(TypeDefinition type, Collection<Instruction> c, PropertyDefinition property, ParameterDefinition left, ParameterDefinition right)
{
var genericInstance = new Lazy<TypeReference>(() => property.PropertyType.GetGenericInstanceType(type));
var getMethodImported = ReferenceFinder.ImportCustom(property.GetGetMethod(type));
c.Add(Instruction.Create(type.GetLdArgForType(), left));
c.Add(Instruction.Create(getMethodImported.GetCallForMethod(), getMethodImported));
if (property.PropertyType.IsValueType || property.PropertyType.IsGenericParameter)
{
c.Add(Instruction.Create(OpCodes.Box, genericInstance.Value));
}
c.Add(Instruction.Create(type.GetLdArgForType(), right));
c.Add(Instruction.Create(getMethodImported.GetCallForMethod(), getMethodImported));
if (property.PropertyType.IsValueType || property.PropertyType.IsGenericParameter)
{
c.Add(Instruction.Create(OpCodes.Box, genericInstance.Value));
}
c.Add(Instruction.Create(OpCodes.Call, ReferenceFinder.Object.StaticEquals));
}
示例4: AddNullableProperty
static VariableDefinition AddNullableProperty(PropertyDefinition property, Collection<Instruction> ins, TypeDefinition type, VariableDefinition variable)
{
ins.If(c =>
{
var nullablePropertyResolved = property.PropertyType.Resolve();
var nullablePropertyImported = ReferenceFinder.ImportCustom(property.PropertyType);
ins.Add(Instruction.Create(OpCodes.Ldarg_0));
var getMethod = ReferenceFinder.ImportCustom(property.GetGetMethod(type));
c.Add(Instruction.Create(OpCodes.Call, getMethod));
variable = new VariableDefinition(getMethod.ReturnType);
c.Add(Instruction.Create(OpCodes.Stloc, variable));
c.Add(Instruction.Create(OpCodes.Ldloca, variable));
var hasValuePropertyResolved = nullablePropertyResolved.Properties.First(x => x.Name == "HasValue").Resolve();
var hasMethod = ReferenceFinder.ImportCustom(hasValuePropertyResolved.GetGetMethod(nullablePropertyImported));
c.Add(Instruction.Create(OpCodes.Call, hasMethod));
},
t =>
{
var nullableProperty = ReferenceFinder.ImportCustom(property.PropertyType);
t.Add(Instruction.Create(OpCodes.Ldarg_0));
var imp = property.GetGetMethod(type);
var imp2 = ReferenceFinder.ImportCustom(imp);
t.Add(Instruction.Create(OpCodes.Call, imp2));
t.Add(Instruction.Create(OpCodes.Box, nullableProperty));
t.Add(Instruction.Create(OpCodes.Callvirt, ReferenceFinder.Object.GetHashcode));
},
e => e.Add(Instruction.Create(OpCodes.Ldc_I4_0)));
return variable;
}
示例5: LoadVariable
static void LoadVariable(PropertyDefinition property, Collection<Instruction> ins, TypeDefinition type)
{
var get = property.GetGetMethod(type);
var imported = ReferenceFinder.ImportCustom(get);
ins.Add(Instruction.Create(OpCodes.Ldarg_0));
ins.Add(Instruction.Create(OpCodes.Call, imported));
}
示例6: AddSimpleValueCheck
private static void AddSimpleValueCheck(Collection<Instruction> c, PropertyDefinition property, TypeDefinition type)
{
c.Add(Instruction.Create(OpCodes.Ldarg_0));
c.Add(Instruction.Create(OpCodes.Callvirt, property.GetGetMethod(type)));
c.Add(Instruction.Create(OpCodes.Ldarg_1));
c.Add(Instruction.Create(OpCodes.Callvirt, property.GetGetMethod(type)));
c.Add(Instruction.Create(OpCodes.Ceq));
}
示例7: AddNormalCheck
private static void AddNormalCheck(TypeDefinition type, Collection<Instruction> c, PropertyDefinition property, TypeDefinition propType)
{
c.Add(Instruction.Create(OpCodes.Ldarg_0));
c.Add(Instruction.Create(OpCodes.Callvirt, property.GetGetMethod(type)));
if (property.PropertyType.IsValueType)
{
c.Add(Instruction.Create(OpCodes.Box, property.PropertyType));
}
c.Add(Instruction.Create(OpCodes.Ldarg_1));
c.Add(Instruction.Create(OpCodes.Callvirt, property.GetGetMethod(type)));
if (property.PropertyType.IsValueType)
{
c.Add(Instruction.Create(OpCodes.Box, property.PropertyType));
}
c.Add(Instruction.Create(OpCodes.Call, ReferenceFinder.Object.StaticEquals));
}
示例8: AddCollectionEquals
private static void AddCollectionEquals(TypeDefinition type, MethodDefinition collectionEquals, PropertyDefinition property, TypeDefinition propType, Collection<Instruction> e)
{
e.If(
cf =>
{
cf.Add(Instruction.Create(OpCodes.Ldarg_1));
cf.Add(Instruction.Create(OpCodes.Ldnull));
cf.Add(Instruction.Create(OpCodes.Ceq));
},
t => { t.Add(Instruction.Create(OpCodes.Ldc_I4_0)); },
es =>
{
es.Add(Instruction.Create(OpCodes.Ldarg_0));
es.Add(Instruction.Create(OpCodes.Callvirt, property.GetGetMethod(type)));
if (propType.IsValueType)
{
es.Add( Instruction.Create( OpCodes.Box, propType ) );
}
es.Add(Instruction.Create(OpCodes.Ldarg_1));
es.Add(Instruction.Create(OpCodes.Callvirt, property.GetGetMethod(type)));
if (propType.IsValueType)
{
es.Add( Instruction.Create( OpCodes.Box, propType ) );
}
es.Add(Instruction.Create(OpCodes.Call, collectionEquals));
});
}
示例9: AddPropertyCode
private void AddPropertyCode(MethodBody body, int index, PropertyDefinition property, TypeDefinition targetType, Collection<VariableDefinition> variables)
{
var ins = body.Instructions;
ins.Add(Instruction.Create(OpCodes.Ldloc_0));
ins.Add(Instruction.Create(OpCodes.Ldc_I4, index));
var get = ModuleDefinition.Import(property.GetGetMethod(targetType));
ins.Add(Instruction.Create(OpCodes.Ldarg_0));
ins.Add(Instruction.Create(OpCodes.Call, get));
if ( get.ReturnType.IsValueType)
{
var returnType = ModuleDefinition.Import(property.GetMethod.ReturnType);
if( returnType.FullName == "System.DateTime" )
{
var convertToUtc = ModuleDefinition.Import(returnType.Resolve().FindMethod( "ToUniversalTime" ));
var variable = new VariableDefinition(returnType);
variables.Add(variable);
ins.Add(Instruction.Create(OpCodes.Stloc, variable));
ins.Add(Instruction.Create(OpCodes.Ldloca, variable));
ins.Add(Instruction.Create(OpCodes.Call, convertToUtc));
}
ins.Add(Instruction.Create(OpCodes.Box, returnType));
}
else
{
var propType = property.PropertyType.Resolve();
var isCollection = !property.PropertyType.IsGenericParameter && propType.IsCollection();
if (isCollection)
{
AssignFalseToFirstFLag(ins);
If(ins,
nc => nc.Add(Instruction.Create(OpCodes.Dup)),
nt =>
{
GetEnumerator(nt);
NewStringBuilder(nt);
AppendString(nt, "[");
While(nt,
c =>
{
c.Add(Instruction.Create(OpCodes.Ldloc_2));
c.Add(Instruction.Create(OpCodes.Callvirt, moveNext));
},
b =>
{
AppendSeparator(b, appendString);
ins.Add(Instruction.Create(OpCodes.Ldloc_1));
If(ins,
c =>
{
c.Add(Instruction.Create(OpCodes.Ldloc_2));
c.Add(Instruction.Create(OpCodes.Callvirt, current));
},
t =>
{
t.Add(Instruction.Create(OpCodes.Call, getInvariantCulture));
string format;
var collectionType = ((GenericInstanceType)property.PropertyType).GenericArguments[0];
if (HaveToAddQuotes(collectionType))
{
format = "\"{0}\"";
}
else
{
format = "{0}";
}
t.Add(Instruction.Create(OpCodes.Ldstr, format));
t.Add(Instruction.Create(OpCodes.Ldc_I4, 1));
t.Add(Instruction.Create(OpCodes.Newarr, ModuleDefinition.TypeSystem.Object));
t.Add(Instruction.Create(OpCodes.Stloc, body.Variables[4]));
t.Add(Instruction.Create(OpCodes.Ldloc, body.Variables[4]));
t.Add(Instruction.Create(OpCodes.Ldc_I4_0));
t.Add(Instruction.Create(OpCodes.Ldloc_2));
t.Add(Instruction.Create(OpCodes.Callvirt, current));
t.Add(Instruction.Create(OpCodes.Stelem_Ref));
t.Add(Instruction.Create(OpCodes.Ldloc, body.Variables[4]));
t.Add(Instruction.Create(OpCodes.Call, formatMethod));
},
e => e.Add(Instruction.Create(OpCodes.Ldstr, "null")));
ins.Add(Instruction.Create(OpCodes.Callvirt, appendString));
ins.Add(Instruction.Create(OpCodes.Pop));
});
//.........这里部分代码省略.........
示例10: LoadVariable
private static void LoadVariable(PropertyDefinition property, Collection<Instruction> ins, TypeDefinition type)
{
var get = property.GetGetMethod(type);
ins.Add(Instruction.Create(OpCodes.Ldarg_0));
ins.Add(Instruction.Create(OpCodes.Call, get));
}