Esempio n. 1
0
        /// <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>
        /// Deep-clone the code object.
        /// </summary>
        public override CodeObject Clone()
        {
            GenericMethodDecl clone = (GenericMethodDecl)base.Clone();

            clone._typeParameters    = ChildListHelpers.Clone(_typeParameters, clone);
            clone._constraintClauses = ChildListHelpers.Clone(_constraintClauses, clone);
            return(clone);
        }