本文整理汇总了C#中Collection.IfNot方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.IfNot方法的具体用法?C# Collection.IfNot怎么用?C# Collection.IfNot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection.IfNot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddCustomLogicCall
static void AddCustomLogicCall(TypeDefinition type, MethodBody body, Collection<Instruction> ins, MethodDefinition[] customLogic)
{
ins.IfNot(
c =>
{
var customMethod = ReferenceFinder.ImportCustom(customLogic[0]);
var parameters = customMethod.Parameters;
if (parameters.Count != 1)
{
throw new WeavingException(
string.Format("Custom equals of type {0} have to have one parameter.", type.FullName));
}
if (parameters[0].ParameterType.Resolve().FullName != type.FullName)
{
throw new WeavingException(
string.Format("Custom equals of type {0} have to have one parameter of type {0}.", type.FullName));
}
MethodReference selectedMethod;
TypeReference resolverType;
if (customMethod.DeclaringType.HasGenericParameters)
{
var genericInstanceType = type.GetGenericInstanceType(type);
resolverType = ReferenceFinder.ImportCustom(genericInstanceType);
var newRef = new MethodReference(customMethod.Name, customMethod.ReturnType)
{
DeclaringType = resolverType,
HasThis = true,
};
newRef.Parameters.Add(customMethod.Parameters[0].Name, resolverType);
selectedMethod = newRef;
}
else
{
resolverType = type;
selectedMethod = customMethod;
}
var imported = ReferenceFinder.ImportCustom(selectedMethod);
if (!type.IsValueType)
{
ins.Add(Instruction.Create(OpCodes.Ldarg_0));
}
else
{
var argVariable = body.Variables.Add("argVariable", resolverType);
ins.Add(Instruction.Create(OpCodes.Ldarg_0));
ins.Add(Instruction.Create(OpCodes.Stloc, argVariable));
ins.Add(Instruction.Create(OpCodes.Ldloca, argVariable));
}
ins.Add(Instruction.Create(OpCodes.Ldarg_1));
ins.Add(Instruction.Create(imported.GetCallForMethod(), imported));
},
AddReturnFalse);
}
示例2: AddPropertyCode
static void AddPropertyCode(TypeDefinition type, MethodDefinition collectionEquals, PropertyDefinition property, Collection<Instruction> ins,ParameterDefinition left,ParameterDefinition right)
{
ins.IfNot(
c =>
{
if (!property.PropertyType.IsGenericParameter)
{
var propType = property.PropertyType.Resolve();
var isCollection = propType.IsCollection();
if (simpleTypes.Contains(propType.FullName) || propType.IsEnum)
{
AddSimpleValueCheck(c, property, type,left,right);
}
else if (!isCollection || propType.FullName == typeof (string).FullName)
{
AddNormalCheck(type, c, property,left,right);
}
else
{
AddCollectionCheck(type, collectionEquals, c, property, propType,left,right);
}
}
else
{
var genericType = property.PropertyType.GetGenericInstanceType(type);
AddNormalCheck(type, c, property,left,right);
}
},
AddReturnFalse);
}
示例3: AddPropertyCode
private static void AddPropertyCode(TypeDefinition type, MethodDefinition collectionEquals, PropertyDefinition property, Collection<Instruction> ins)
{
var propType = property.PropertyType.Resolve();
var isCollection = propType.IsCollection();
ins.IfNot(
c =>
{
if (simpleTypes.Contains(propType.FullName) || propType.IsEnum)
{
AddSimpleValueCheck(c, property, type);
}
else if (!isCollection || propType.FullName == typeof (string).FullName)
{
AddNormalCheck(type, c, property, propType);
}
else
{
AddCollectionCheck(type, collectionEquals, c, property, propType);
}
},
t => AddReturnFalse(t));
}