Ejemplo n.º 1
0
        private static TypeDefinitionName Translate <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly>(Type type, IOutput output, IDecodeMetaData <Local, Parameter, Method, Field, Property, Event, Type, Attribute, Assembly> mdDecoder)
        {
            Type parent;

            if (mdDecoder.IsNested(type, out parent))
            {
                TypeDefinitionName parentDef = Translate(parent, output, mdDecoder);

                TypeDefinitionName nested = TypeDefinitionName.FromName(0, mdDecoder.IsStruct(type), parentDef, mdDecoder.Name(type));
                return(nested);
            }

            string moduleName = mdDecoder.DeclaringModuleName(type);

            if (moduleName == null)
            {
                // can't translate this as a type definition
                output.WriteLine("Can't translate type {0} as a type definition", mdDecoder.Name(type));
                throw new NotImplementedException();
            }

            Microsoft.Research.DataStructures.IIndexable <Type> formals;
            string[] args;
            if (mdDecoder.IsGeneric(type, out formals, true))
            {
                args = TranslateTypeFormals(formals, output, mdDecoder);
            }
            else
            {
                args = new string[0];
            }
            return(TypeDefinitionName.FromName(ShortAssemblyName.FromName(mdDecoder.DeclaringModuleName(type)), 0, mdDecoder.IsStruct(type), mdDecoder.Namespace(type), mdDecoder.Name(type), args));
        }