public override string GenerateMapperIndex(string emptyLine)
        {
            TSBuilder builder = new TSBuilder();

            CompositeTypeTS[] orderedMapperTemplateModels = OrderedMapperTemplateModels.ToArray();

            builder.Import(new[] { "CloudErrorMapper", "BaseResourceMapper" }, "ms-rest-azure-js");

            ImportMsRestForMappers(builder, orderedMapperTemplateModels);

            builder.Line(emptyLine);

            builder.ExportConst("CloudError", "CloudErrorMapper");
            builder.ExportConst("BaseResource", "BaseResourceMapper");

            ExportOrderedMapperModels(builder, orderedMapperTemplateModels, emptyLine);

            foreach (PageCompositeTypeTSa pageModel in PageTemplateModels)
            {
                builder.Line(emptyLine);
                pageModel.ConstructModelMapper(builder);
            }

            ExportPolymorphicDictionary(builder, emptyLine);

            return(builder.ToString());
        }
Beispiel #2
0
        public string GenerateAzureServiceClientImports()
        {
            TSBuilder builder = new TSBuilder();

            builder.ImportAllAs("msRest", "@azure/ms-rest-js");

            bool usesAzureOptionsType = OptionalParameterTypeForClientConstructor == "AzureServiceClientOptions";

            if (usesAzureOptionsType || MethodTemplateModels.Any((MethodTS method) => method.IsLongRunningOperation))
            {
                builder.ImportAllAs("msRestAzure", "@azure/ms-rest-azure-js");
            }

            if (CodeGeneratorTS.ShouldWriteModelsFiles(this))
            {
                builder.ImportAllAs("Models", "./models");
            }
            if (HasMappers())
            {
                builder.ImportAllAs("Mappers", "./models/mappers");
            }

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "./models/parameters");
            }

            if (MethodGroupModels.Any())
            {
                builder.ImportAllAs("operations", "./operations");
            }
            builder.Import(new string[] { ContextName }, $"./{ContextName.ToCamelCase()}");

            return(builder.ToString());
        }
        public string GenerateServiceClientImports()
        {
            TSBuilder builder = new TSBuilder();

            if (MethodTemplateModels.Any() || OptionalParameterTypeForClientConstructor == ServiceClientOptions)
            {
                builder.ImportAllAs("msRest", "ms-rest-js");
            }

            if (CodeGeneratorTS.ShouldWriteModelsFiles(this))
            {
                builder.ImportAllAs("Models", "./models");
            }

            if (CodeGeneratorTS.ShouldWriteMappersIndexFile(this))
            {
                builder.ImportAllAs("Mappers", "./models/mappers");
            }

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "./models/parameters");
            }

            if (CodeGeneratorTS.ShouldWriteMethodGroupFiles(this))
            {
                builder.ImportAllAs("operations", "./operations");
            }
            builder.Import(new string[] { ContextName }, $"./{ContextName.ToCamelCase()}");

            return(builder.ToString());
        }
        public string GenerateMethodGroupImports()
        {
            TSBuilder builder = new TSBuilder();

            builder.ImportAllAs("msRest", "ms-rest-js");
            if (MethodTemplateModels.Any((MethodTS method) => method.IsLongRunningOperation))
            {
                builder.ImportAllAs("msRestAzure", "ms-rest-azure-js");
            }

            CodeModelTS codeModel = CodeModelTS;

            if (CodeGeneratorTS.ShouldWriteModelsFiles(codeModel))
            {
                if (ContainsCompositeOrEnumTypeInParametersOrReturnType() || MethodTemplateModels.Any(m => m.HasCustomHttpResponseType))
                {
                    builder.ImportAllAs("Models", "../models");
                }
                if (codeModel.HasMappers())
                {
                    builder.ImportAllAs("Mappers", $"../models/{MappersModuleName}");
                }
            }

            if (HasMappableParameters)
            {
                builder.ImportAllAs("Parameters", "../models/parameters");
            }

            builder.Import(new string[] { codeModel.ContextName }, $"../{codeModel.ContextName.ToCamelCase()}");

            return(builder.ToString());
        }
 public virtual void ConstructRuntimeImportForModelIndex(TSBuilder builder)
 {
     if (OptionalParameterTypeForClientConstructor != ServiceClientOptions)
     {
         builder.Import(new string[] { ServiceClientOptions }, "@azure/ms-rest-js");
     }
 }
        public virtual string ConstructRuntimeImportForModelIndex()
        {
            TSBuilder builder = new TSBuilder();

            if (OptionalParameterTypeForClientConstructor != ServiceClientOptions)
            {
                builder.Import(new string[] { ServiceClientOptions }, "ms-rest-js");
            }
            return(builder.ToString());
        }
Beispiel #7
0
        public override void ConstructRuntimeImportForModelIndex(TSBuilder builder)
        {
            List <string> imports = new List <string>()
            {
                "BaseResource", "CloudError"
            };

            if (OptionalParameterTypeForClientConstructor != "AzureServiceClientOptions")
            {
                imports.Add("AzureServiceClientOptions");
            }
            builder.Import(imports, "@azure/ms-rest-azure-js");
        }
Beispiel #8
0
 protected void GenerateNodeSampleClientImport(TSBuilder builder)
 {
     builder.Import(new[] { Name, $"{ClientPrefix}Models", $"{ClientPrefix}Mappers" }, PackageName);
 }