Ejemplo n.º 1
0
        public override void AppendOutput(TypeScriptModule module)
        {
            BeginModule(module);

            var interfaceAppender = new InterfaceOutputAppender(Output, BaseIndentation + 4, module.IsGlobal);

            foreach (var tsInterface in module.Interfaces)
            {
                interfaceAppender.AppendOutput(tsInterface);
            }

            EndModule(module);
        }
Ejemplo n.º 2
0
        private void AppendInterfacesInCreatedOrder(
            StringBuilder output,
            int indent,
            TypeScriptModule module)
        {
            InterfaceOutputAppender interfaceAppender = new InterfaceOutputAppender(
                this.Settings,
                this.TypeContext,
                module.IsGlobal);

            foreach (var tsInterface in module.Interfaces
                     .OrderBy((currentInterface) => currentInterface.SourceType.RawName))
            {
                interfaceAppender.AppendOutput(
                    output,
                    indent,
                    tsInterface);
            }
        }
        public override void AppendOutput(TypeScriptModule module)
        {
            BeginModule(module);

            var enumAppender = new EnumOutputAppender(Output, BaseIndentation + 4, Settings);

            foreach (TypeScriptEnum tsEnum in module.Enums)
            {
                enumAppender.AppendOutput(tsEnum);
            }

            var interfaceAppender = new InterfaceOutputAppender(Output, BaseIndentation + 4, Settings, module.IsGlobal);

            foreach (TypeScriptInterface tsInterface in module.Interfaces)
            {
                interfaceAppender.AppendOutput(tsInterface);
            }

            EndModule(module);
        }
Ejemplo n.º 4
0
        private void AppendInterfacesInReferenceOrder(
            StringBuilder output,
            int indent,
            TypeScriptModule module)
        {
            InterfaceOutputAppender interfaceAppender = new InterfaceOutputAppender(
                this.Settings,
                this.TypeContext,
                module.IsGlobal);

            HashSet <string> outputTypeNames = new HashSet <string>();
            int handledCount = 0;
            IList <TypeReference> allTypeReferences = new List <TypeReference>(this.TypeContext.GetTypeReferences());

            while (handledCount < allTypeReferences.Count)
            {
                for (; handledCount < allTypeReferences.Count; handledCount++)
                {
                    this.AppendType(
                        output,
                        indent,
                        allTypeReferences[handledCount],
                        outputTypeNames,
                        interfaceAppender,
                        module);
                }

                allTypeReferences = new List <TypeReference>(this.TypeContext.GetTypeReferences());
            }

            foreach (TypeScriptInterface currentInterface in module.Interfaces)
            {
                if (!outputTypeNames.Contains(currentInterface.SourceType.UniversalName))
                {
                    interfaceAppender.AppendOutput(
                        output,
                        indent,
                        currentInterface);
                }
            }
        }
Ejemplo n.º 5
0
        private void AppendType(
            StringBuilder output,
            int indent,
            TypeReference typeReference,
            HashSet <string> outputTypeNames,
            InterfaceOutputAppender interfaceAppender,
            TypeScriptModule currentModule)
        {
            if (!outputTypeNames.Contains(typeReference.SourceType.UniversalName))
            {
                TypeScriptInterface interfaceType = this.TypeContext.GetInterface(typeReference.SourceType);
                if (interfaceType != null &&
                    currentModule.Interfaces.Contains(interfaceType))
                {
                    if (interfaceType.Parent != null)
                    {
                        this.AppendType(
                            output,
                            indent,
                            interfaceType.Parent,
                            outputTypeNames,
                            interfaceAppender,
                            currentModule);
                    }

                    // More reference handling...

                    if (!outputTypeNames.Contains(typeReference.SourceType.UniversalName))
                    {
                        interfaceAppender.AppendOutput(
                            output,
                            indent,
                            interfaceType);
                        outputTypeNames.Add(typeReference.SourceType.UniversalName);
                    }
                }
            }
        }