本文整理汇总了C#中ITypeDefinition.GetDelegateInvokeMethod方法的典型用法代码示例。如果您正苦于以下问题:C# ITypeDefinition.GetDelegateInvokeMethod方法的具体用法?C# ITypeDefinition.GetDelegateInvokeMethod怎么用?C# ITypeDefinition.GetDelegateInvokeMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITypeDefinition
的用法示例。
在下文中一共展示了ITypeDefinition.GetDelegateInvokeMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Visit
public TsType Visit(ITypeDefinition ce)
{
var name = SkJs.GetEntityJsName(ce);
var ce2 = new TsType
{
Name = name, Kind=(ce.IsInterface() || ce.IsDelegate()) ? TsTypeKind.Interface : TsTypeKind.Class,
TypeParameters = ce.TypeParameters.Select(Visit).ToList()
};
if (name.Contains("."))
{
var pair = name.SplitAt(name.LastIndexOf("."), true);
ce2.Name = pair[1];
ce2.ModuleName = pair[0];
ce2.IsModuleExport = true;
}
if (ce.IsDelegate())
{
var func = Visit(ce.GetDelegateInvokeMethod());
//func.IsCallSignature = true;
func.Name = null;
ce2.Members.Add(func);
}
else
{
var members = TypeConverter.ClrConverter.GetMembersToExport(ce);
var members2 = members.Select(Visit).Where(t => t != null).ToList();
ce2.Members.AddRange(members2);
if (ce2.Kind == TsTypeKind.Class)
{
ce2.Members.OfType<TsFunction>().Where(t => !t.IsConstructor || !t.Type.IsNullOrVoid()).ForEach(t => t.Body = "return null;");
ce2.Members.OfType<TsFunction>().Where(t => t.IsConstructor).ForEach(t => t.Body = "");
}
}
return ce2;
}
示例2: ConvertTypeDefinition
EntityDeclaration ConvertTypeDefinition(ITypeDefinition typeDefinition)
{
Modifiers modifiers = Modifiers.None;
if (this.ShowAccessibility) {
modifiers |= ModifierFromAccessibility(typeDefinition.Accessibility);
}
if (this.ShowModifiers) {
if (typeDefinition.IsStatic) {
modifiers |= Modifiers.Static;
} else if (typeDefinition.IsAbstract) {
modifiers |= Modifiers.Abstract;
} else if (typeDefinition.IsSealed) {
modifiers |= Modifiers.Sealed;
}
if (typeDefinition.IsShadowing) {
modifiers |= Modifiers.New;
}
}
ClassType classType;
switch (typeDefinition.Kind) {
case TypeKind.Struct:
classType = ClassType.Struct;
modifiers &= ~Modifiers.Sealed;
break;
case TypeKind.Enum:
classType = ClassType.Enum;
modifiers &= ~Modifiers.Sealed;
break;
case TypeKind.Interface:
classType = ClassType.Interface;
modifiers &= ~Modifiers.Abstract;
break;
case TypeKind.Delegate:
IMethod invoke = typeDefinition.GetDelegateInvokeMethod();
if (invoke != null) {
return ConvertDelegate(invoke, modifiers);
} else {
goto default;
}
default:
classType = ClassType.Class;
break;
}
var decl = new TypeDeclaration();
decl.ClassType = classType;
decl.Modifiers = modifiers;
decl.Name = typeDefinition.Name;
int outerTypeParameterCount = (typeDefinition.DeclaringTypeDefinition == null) ? 0 : typeDefinition.DeclaringTypeDefinition.TypeParameterCount;
if (this.ShowTypeParameters) {
foreach (ITypeParameter tp in typeDefinition.TypeParameters.Skip(outerTypeParameterCount)) {
decl.TypeParameters.Add(ConvertTypeParameter(tp));
}
}
if (this.ShowBaseTypes) {
foreach (IType baseType in typeDefinition.DirectBaseTypes) {
decl.BaseTypes.Add(ConvertType(baseType));
}
}
if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
var constraint = ConvertTypeParameterConstraint(tp);
if (constraint != null)
decl.Constraints.Add(constraint);
}
}
return decl;
}
示例3: ProcessDelegate
private void ProcessDelegate(ITypeDefinition delegateDefinition) {
bool bindThisToFirstParameter = AttributeReader.HasAttribute<BindThisToFirstParameterAttribute>(delegateDefinition);
bool expandParams = AttributeReader.HasAttribute<ExpandParamsAttribute>(delegateDefinition);
if (bindThisToFirstParameter && delegateDefinition.GetDelegateInvokeMethod().Parameters.Count == 0) {
Message(Messages._7147, delegateDefinition, delegateDefinition.FullName);
bindThisToFirstParameter = false;
}
if (expandParams && !delegateDefinition.GetDelegateInvokeMethod().Parameters.Any(p => p.IsParams)) {
Message(Messages._7148, delegateDefinition, delegateDefinition.FullName);
expandParams = false;
}
_delegateSemantics[delegateDefinition] = new DelegateScriptSemantics(expandParams: expandParams, bindThisToFirstParameter: bindThisToFirstParameter);
}
示例4: ConvertTypeDefinition
AttributedNode ConvertTypeDefinition(ITypeDefinition typeDefinition)
{
Modifiers modifiers = ModifierFromAccessibility(typeDefinition.Accessibility);
if (this.ShowModifiers) {
if (typeDefinition.IsStatic) {
modifiers |= Modifiers.Static;
} else if (typeDefinition.IsAbstract) {
modifiers |= Modifiers.Abstract;
} else if (typeDefinition.IsSealed) {
modifiers |= Modifiers.Sealed;
}
if (typeDefinition.IsShadowing) {
modifiers |= Modifiers.New;
}
}
ClassType classType;
switch (typeDefinition.Kind) {
case TypeKind.Struct:
classType = ClassType.Struct;
break;
case TypeKind.Enum:
classType = ClassType.Enum;
break;
case TypeKind.Interface:
classType = ClassType.Interface;
break;
case TypeKind.Delegate:
IMethod invoke = typeDefinition.GetDelegateInvokeMethod();
if (invoke != null)
return ConvertDelegate(invoke, modifiers);
else
goto default;
default:
classType = ClassType.Class;
break;
}
TypeDeclaration decl = new TypeDeclaration();
decl.Modifiers = modifiers;
decl.ClassType = classType;
decl.Name = typeDefinition.Name;
if (this.ShowTypeParameters) {
foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
decl.TypeParameters.Add(ConvertTypeParameter(tp));
}
}
if (this.ShowBaseTypes) {
foreach (ITypeReference baseType in typeDefinition.BaseTypes) {
decl.BaseTypes.Add(ConvertTypeReference(baseType));
}
}
if (this.ShowTypeParameters && this.ShowTypeParameterConstraints) {
foreach (ITypeParameter tp in typeDefinition.TypeParameters) {
var constraint = ConvertTypeParameterConstraint(tp);
if (constraint != null)
decl.Constraints.Add(constraint);
}
}
return decl;
}