Exemplo n.º 1
0
        public Wizard(ConnectedServiceProviderContext context)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
            this.Context                  = context;
            this.ProjectPath              = context.ProjectHierarchy?.GetProject().Properties.Item("FullPath").Value.ToString();
            this.UserSettings             = UserSettings.Load(context.Logger);
            this.UserSettings.ProjectPath = this.ProjectPath;

            if (this.Context.IsUpdating)
            {
                this.UserSettings.SetFromServiceConfiguration(context.GetExtendedDesignerData <ServiceConfiguration>());
            }

            ConfigOpenApiEndpointViewModel    = new ConfigOpenApiEndpointViewModel(this.UserSettings, this);
            CSharpClientSettingsViewModel     = new CSharpClientSettingsViewModel();
            TypeScriptClientSettingsViewModel = new TypeScriptClientSettingsViewModel();
            CSharpControllerSettingsViewModel = new CSharpControllerSettingsViewModel();

            if (this.Context.IsUpdating)
            {
                var serviceConfig = this.Context.GetExtendedDesignerData <ServiceConfiguration>();
                ConfigOpenApiEndpointViewModel.Endpoint    = serviceConfig.Endpoint;
                ConfigOpenApiEndpointViewModel.ServiceName = serviceConfig.ServiceName;
                ConfigOpenApiEndpointViewModel.UseWebProxy = serviceConfig.UseWebProxy;
                ConfigOpenApiEndpointViewModel.NetworkCredentialsDomain           = serviceConfig.NetworkCredentialsDomain;
                ConfigOpenApiEndpointViewModel.NetworkCredentialsUserName         = serviceConfig.NetworkCredentialsUserName;
                ConfigOpenApiEndpointViewModel.NetworkCredentialsPassword         = serviceConfig.NetworkCredentialsPassword;
                ConfigOpenApiEndpointViewModel.WebProxyNetworkCredentialsDomain   = serviceConfig.WebProxyNetworkCredentialsDomain;
                ConfigOpenApiEndpointViewModel.WebProxyNetworkCredentialsUserName = serviceConfig.WebProxyNetworkCredentialsUserName;
                ConfigOpenApiEndpointViewModel.WebProxyNetworkCredentialsPassword = serviceConfig.WebProxyNetworkCredentialsPassword;
                ConfigOpenApiEndpointViewModel.UseNetworkCredentials = serviceConfig.UseNetworkCredentials;
                ConfigOpenApiEndpointViewModel.WebProxyUri           = serviceConfig.WebProxyUri;
                ConfigOpenApiEndpointViewModel.Description           =
                    "An OpenAPI (Swagger) specification endpoint and generation options was regenerated";
                if (ConfigOpenApiEndpointViewModel.View is ConfigOpenApiEndpoint сonfigOpenApiEndpoint)
                {
                    //сonfigOpenApiEndpoint.Endpoint.IsEnabled = false;
                    //сonfigOpenApiEndpoint.ServiceName.IsEnabled = false;
                }

                CSharpClientSettingsViewModel.Command = serviceConfig.OpenApiToCSharpClientCommand;
                CSharpClientSettingsViewModel.ExcludeTypeNamesLater = serviceConfig.ExcludeTypeNamesLater;
                CSharpClientSettingsViewModel.Description           = "Settings for generating CSharp client (regenerated)";
                TypeScriptClientSettingsViewModel.Command           = serviceConfig.OpenApiToTypeScriptClientCommand;
                TypeScriptClientSettingsViewModel.Description       = "Settings for generating TypeScript client (regenerated)";
                CSharpControllerSettingsViewModel.Command           = serviceConfig.OpenApiToCSharpControllerCommand;
                CSharpControllerSettingsViewModel.Description       = "Settings for generating CSharp controller (regenerated)";
            }

            this.Pages.Add(ConfigOpenApiEndpointViewModel);
            this.IsFinishEnabled = true;
        }
Exemplo n.º 2
0
        public Wizard(ConnectedServiceProviderContext context)
        {
            this.Context      = context;
            this.UserSettings = UserSettings.Load(context.Logger);

            ConfigOpenApiEndpointViewModel    = new ConfigOpenApiEndpointViewModel(this.UserSettings, this);
            CSharpClientSettingsViewModel     = new CSharpClientSettingsViewModel();
            TypeScriptClientSettingsViewModel = new TypeScriptClientSettingsViewModel();
            CSharpControllerSettingsViewModel = new CSharpControllerSettingsViewModel();

            if (this.Context.IsUpdating)
            {
                var serviceConfig = this.Context.GetExtendedDesignerData <ServiceConfiguration>();
                ConfigOpenApiEndpointViewModel.Endpoint    = serviceConfig.Endpoint;
                ConfigOpenApiEndpointViewModel.ServiceName = serviceConfig.ServiceName;
                ConfigOpenApiEndpointViewModel.UseWebProxy = serviceConfig.UseWebProxy;
                ConfigOpenApiEndpointViewModel.NetworkCredentialsDomain           = serviceConfig.NetworkCredentialsDomain;
                ConfigOpenApiEndpointViewModel.NetworkCredentialsUserName         = serviceConfig.NetworkCredentialsUserName;
                ConfigOpenApiEndpointViewModel.NetworkCredentialsPassword         = serviceConfig.NetworkCredentialsPassword;
                ConfigOpenApiEndpointViewModel.WebProxyNetworkCredentialsDomain   = serviceConfig.WebProxyNetworkCredentialsDomain;
                ConfigOpenApiEndpointViewModel.WebProxyNetworkCredentialsUserName = serviceConfig.WebProxyNetworkCredentialsUserName;
                ConfigOpenApiEndpointViewModel.WebProxyNetworkCredentialsPassword = serviceConfig.WebProxyNetworkCredentialsPassword;
                ConfigOpenApiEndpointViewModel.UseNetworkCredentials = serviceConfig.UseNetworkCredentials;
                ConfigOpenApiEndpointViewModel.WebProxyUri           = serviceConfig.WebProxyUri;
                ConfigOpenApiEndpointViewModel.Description           =
                    "An OpenAPI (Swagger) specification endpoint and generation options was regenerated";
                if (ConfigOpenApiEndpointViewModel.View is ConfigOpenApiEndpoint сonfigOpenApiEndpoint)
                {
                    //сonfigOpenApiEndpoint.Endpoint.IsEnabled = false;
                    //сonfigOpenApiEndpoint.ServiceName.IsEnabled = false;
                }

                CSharpClientSettingsViewModel.Command         = serviceConfig.SwaggerToCSharpClientCommand;
                CSharpClientSettingsViewModel.Description     = "Settings for generating CSharp client (regenerated)";
                TypeScriptClientSettingsViewModel.Command     = serviceConfig.SwaggerToTypeScriptClientCommand;
                TypeScriptClientSettingsViewModel.Description = "Settings for generating TypeScript client (regenerated)";
                CSharpControllerSettingsViewModel.Command     = serviceConfig.SwaggerToCSharpControllerCommand;
                CSharpControllerSettingsViewModel.Description = "Settings for generating CSharp controller (regenerated)";
            }

            this.Pages.Add(ConfigOpenApiEndpointViewModel);
            this.IsFinishEnabled = true;
        }