本文整理汇总了C#中ITypeDefinition.GetInvokeMethod方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.GetInvokeMethod方法的具体用法?C# ITypeDefinition.GetInvokeMethod怎么用?C# ITypeDefinition.GetInvokeMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefinition
的用法示例。
在下文中一共展示了ITypeDefinition.GetInvokeMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTypeDeclaration
public void WriteTypeDeclaration(ITypeDefinition type)
{
INamedTypeDefinition namedType = (INamedTypeDefinition)type;
WriteAttributes(type.Attributes);
WriteAttributes(type.SecurityAttributes);
//TODO: We should likely add support for the SerializableAttribute something like:
// if (type.IsSerializable) WriteFakeAttribute("System.Serializable");
// But we need also consider if this attribute is filtered out or not but I guess
// we have the same problem with all the fake attributes at this point.
if (type.IsStruct && type.Layout != LayoutKind.Auto)
{
// What about the Pack, and CharSet properties?
string structLayout = "System.Runtime.InteropServices.StructLayoutAttribute";
string layoutKind = string.Format("System.Runtime.InteropServices.LayoutKind.{0}", type.Layout.ToString());
if (type.SizeOf != 0)
{
string sizeOf = string.Format("Size={0}", type.SizeOf);
WriteFakeAttribute(structLayout, layoutKind, sizeOf);
}
else
{
WriteFakeAttribute(structLayout, layoutKind);
}
}
WriteVisibility(TypeHelper.TypeVisibilityAsTypeMemberVisibility(type));
IMethodDefinition invoke = type.GetInvokeMethod();
if (invoke != null)
{
Contract.Assert(type.IsDelegate);
if (invoke.IsMethodUnsafe()) WriteKeyword("unsafe");
WriteKeyword("delegate");
WriteTypeName(invoke.Type);
WriteIdentifier(namedType.Name);
if (type.IsGeneric) WriteGenericParameters(type.GenericParameters);
WriteParameters(invoke.Parameters);
if (type.IsGeneric) WriteGenericContraints(type.GenericParameters);
WriteSymbol(";");
}
else
{
WriteTypeModifiers(type);
WriteIdentifier(namedType.Name);
Contract.Assert(!(type is IGenericTypeInstance), "Currently don't support generic type instances if we hit this then add support");
if (type.IsGeneric) WriteGenericParameters(type.GenericParameters);
WriteBaseTypes(type);
if (type.IsGeneric) WriteGenericContraints(type.GenericParameters);
if (type.IsEnum)
WriteEnumType(type);
}
}
示例2: Diff
public override DifferenceType Diff(IDifferences differences, ITypeDefinition impl, ITypeDefinition contract)
{
if (impl == null || contract == null)
return DifferenceType.Unknown;
if (!impl.IsDelegate || !contract.IsDelegate)
return DifferenceType.Unknown;
IMethodDefinition implMethod = impl.GetInvokeMethod();
IMethodDefinition contractMethod = contract.GetInvokeMethod();
Contract.Assert(implMethod != null && contractMethod != null);
if (!ReturnTypesMatch(differences, implMethod, contractMethod) ||
!ParamNamesAndTypesMatch(differences, implMethod, contractMethod))
return DifferenceType.Changed;
return DifferenceType.Unknown;
}