/// <summary> /// Get the declaring generic type or method. /// </summary> public TypeRefBase GetDeclaringTypeOrMethod() { object reference = GetReferencedType(); if (reference is TypeParameter) { CodeObject parent = ((TypeParameter)reference).Parent; if (parent is GenericMethodDecl) { GenericMethodDecl methodDecl = (GenericMethodDecl)parent; return(methodDecl.CreateRef(ChildList <Expression> .CreateListOfNulls(methodDecl.TypeParameterCount))); } if (parent is ITypeDecl) { ITypeDecl typeDecl = (ITypeDecl)parent; return(typeDecl.CreateRef(ChildList <Expression> .CreateListOfNulls(typeDecl.TypeParameterCount))); } } else if (reference is Type) { Type typeParameter = (Type)reference; if (typeParameter.DeclaringMethod != null) { return(MethodRef.Create(typeParameter.DeclaringMethod)); } Type declaringType = ((Type)reference).DeclaringType; return(declaringType != null ? Create(declaringType) : null); } return(null); }
/// <summary> /// Create a <see cref="DelegateDecl"/> with the specified name and return type. /// </summary> public DelegateDecl(string name, ITypeDecl returnType) : this(name, returnType.CreateRef(), Modifiers.None) { }
/// <summary> /// Create a <see cref="DelegateDecl"/> with the specified name, return type, modifiers, and type parameters. /// </summary> public DelegateDecl(string name, ITypeDecl returnType, Modifiers modifiers, params TypeParameter[] typeParameters) : this(name, returnType.CreateRef(), modifiers, typeParameters) { }
/// <summary> /// Create a <see cref="DelegateDecl"/> with the specified name and return type. /// </summary> public DelegateDecl(string name, ITypeDecl returnType, Modifiers modifiers) : this(name, returnType.CreateRef(), modifiers) { }