public void Init() { userSettings = new UserSettings(); serviceWizard = new ODataConnectedServiceWizard(null); configOdataEndPointViewModel = new ConfigODataEndpointViewModel(userSettings, serviceWizard); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; }
public ODataConnectedServiceWizard(ConnectedServiceProviderContext context) { this.Context = context; this.userSettings = UserSettings.Load(context.Logger); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(this.userSettings); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(); if (this.Context.IsUpdating) { //Since ServiceConfigurationV4 is a derived type of ServiceConfiguration. So we can deserialize a ServiceConfiguration into a ServiceConfigurationV4. ServiceConfigurationV4 serviceConfig = this.Context.GetExtendedDesignerData <ServiceConfigurationV4>(); ConfigODataEndpointViewModel.Endpoint = serviceConfig.Endpoint; ConfigODataEndpointViewModel.EdmxVersion = serviceConfig.EdmxVersion; ConfigODataEndpointViewModel.ServiceName = serviceConfig.ServiceName; ConfigODataEndpointViewModel.CustomHttpHeaders = serviceConfig.CustomHttpHeaders; var configODataEndpoint = (ConfigODataEndpointViewModel.View as ConfigODataEndpoint); configODataEndpoint.IsEnabled = false; //Restore the advanced settings to UI elements. AdvancedSettingsViewModel.PageEntering += (sender, args) => { var advancedSettingsViewModel = sender as AdvancedSettingsViewModel; if (advancedSettingsViewModel != null) { AdvancedSettings advancedSettings = advancedSettingsViewModel.View as AdvancedSettings; advancedSettingsViewModel.GeneratedFileName = serviceConfig.GeneratedFileNamePrefix; advancedSettings.ReferenceFileName.IsEnabled = false; advancedSettingsViewModel.UseNamespacePrefix = serviceConfig.UseNameSpacePrefix; advancedSettingsViewModel.NamespacePrefix = serviceConfig.NamespacePrefix; advancedSettingsViewModel.UseDataServiceCollection = serviceConfig.UseDataServiceCollection; advancedSettingsViewModel.GenerateMultipleFiles = serviceConfig.GenerateMultipleFiles; advancedSettings.GenerateMultipleFiles.IsEnabled = false; if (serviceConfig.EdmxVersion == Common.Constants.EdmxVersion4) { advancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; advancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; advancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; advancedSettingsViewModel.MakeTypesInternal = serviceConfig.MakeTypesInternal; advancedSettings.IncludeT4File.IsEnabled = false; } } }; } this.Pages.Add(ConfigODataEndpointViewModel); this.Pages.Add(AdvancedSettingsViewModel); this.IsFinishEnabled = true; }
public ODataConnectedServiceWizard(ConnectedServiceProviderContext context) { this.Context = context; this.Project = ProjectHelper.GetProjectFromHierarchy(this.Context.ProjectHierarchy); this.userSettings = UserSettings.Load(context.Logger); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(this.userSettings); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(); AdvancedSettingsViewModel.NamespacePrefix = ProjectHelper.GetProjectNamespace(this.Project); this.Pages.Add(ConfigODataEndpointViewModel); this.Pages.Add(AdvancedSettingsViewModel); this.IsFinishEnabled = true; }
/// <summary> /// Cleanup object references /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { try { if (disposing) { if (AdvancedSettingsViewModel != null) { AdvancedSettingsViewModel.Dispose(); AdvancedSettingsViewModel = null; } if (OperationImportsViewModel != null) { OperationImportsViewModel.Dispose(); OperationImportsViewModel = null; } if (SchemaTypesViewModel != null) { SchemaTypesViewModel.Dispose(); SchemaTypesViewModel = null; } if (ConfigODataEndpointViewModel != null) { ConfigODataEndpointViewModel.Dispose(); ConfigODataEndpointViewModel = null; } if (serviceInstance != null) { serviceInstance.Dispose(); serviceInstance = null; } } } finally { base.Dispose(disposing); } }
public ODataConnectedServiceWizard(ConnectedServiceProviderContext context) { this.Context = context; this.UserSettings = UserSettings.Load(context?.Logger); // Since ServiceConfigurationV4 is a derived type of ServiceConfiguration. So we can deserialize a ServiceConfiguration into a ServiceConfigurationV4. this._serviceConfig = this.Context?.GetExtendedDesignerData <ServiceConfigurationV4>(); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(this.UserSettings, this); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(this.UserSettings); SchemaTypesViewModel = new SchemaTypesViewModel(this.UserSettings); OperationImportsViewModel = new OperationImportsViewModel(this.UserSettings); OperationImportsViewModel.PageEntering += OperationImportsViewModel_PageEntering; SchemaTypesViewModel.PageEntering += SchemaTypeSelectionViewModel_PageEntering; SchemaTypesViewModel.PageLeaving += SchemaTypeSelectionViewModel_PageLeaving; if (this.Context != null && this.Context.IsUpdating) { ConfigODataEndpointViewModel.Endpoint = this._serviceConfig?.Endpoint; ConfigODataEndpointViewModel.EdmxVersion = this._serviceConfig?.EdmxVersion; ConfigODataEndpointViewModel.ServiceName = this._serviceConfig?.ServiceName; ConfigODataEndpointViewModel.CustomHttpHeaders = this._serviceConfig?.CustomHttpHeaders; // Restore the main settings to UI elements. ConfigODataEndpointViewModel.PageEntering += ConfigODataEndpointViewModel_PageEntering; // The ViewModel should always be filled otherwise if the wizard is completed without visiting this page the generated code becomes wrong AdvancedSettingsViewModel_PageEntering(AdvancedSettingsViewModel, EventArgs.Empty); // Restore the advanced settings to UI elements. AdvancedSettingsViewModel.PageEntering += AdvancedSettingsViewModel_PageEntering; } this.Pages.Add(ConfigODataEndpointViewModel); this.Pages.Add(SchemaTypesViewModel); this.Pages.Add(OperationImportsViewModel); this.Pages.Add(AdvancedSettingsViewModel); this.IsFinishEnabled = true; }
public ODataConnectedServiceWizard(ConnectedServiceProviderContext context) { Context = context; // We only use most recently used endpoints from the config file saved in user's isolated storage // The UserSettings constructor will load those endpoints UserSettings = new UserSettings(context?.Logger); // Since ServiceConfigurationV4 is a derived type of ServiceConfiguration, // we can deserialize a ServiceConfiguration into a ServiceConfigurationV4. ServiceConfig = Context?.GetExtendedDesignerData <ServiceConfigurationV4>(); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(UserSettings); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(UserSettings); SchemaTypesViewModel = new SchemaTypesViewModel(UserSettings); OperationImportsViewModel = new OperationImportsViewModel(UserSettings); OperationImportsViewModel.PageEntering += OperationImportsViewModel_PageEntering; SchemaTypesViewModel.PageEntering += SchemaTypeSelectionViewModel_PageEntering; SchemaTypesViewModel.PageLeaving += SchemaTypeSelectionViewModel_PageLeaving; if (Context != null && Context.IsUpdating) { LoadUserSettingsFromServiceConfig(); ConfigODataEndpointViewModel.EdmxVersion = ServiceConfig?.EdmxVersion; // Restore the main settings to UI elements. ConfigODataEndpointViewModel.PageEntering += ConfigODataEndpointViewModel_PageEntering; // The ViewModel should always be filled otherwise if the wizard is completed without visiting this page the generated code becomes wrong AdvancedSettingsViewModel_PageEntering(AdvancedSettingsViewModel, EventArgs.Empty); // Restore the advanced settings to UI elements. AdvancedSettingsViewModel.PageEntering += AdvancedSettingsViewModel_PageEntering; } Pages.Add(ConfigODataEndpointViewModel); Pages.Add(SchemaTypesViewModel); Pages.Add(OperationImportsViewModel); Pages.Add(AdvancedSettingsViewModel); IsFinishEnabled = true; }
public Wizard(ConnectedServiceProviderContext context) { this.Context = context; this.UserSettings = UserSettings.Load(context.Logger); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(this.UserSettings, this); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(this.UserSettings, this); FunctionImportsViewModel = new FunctionImportsViewModel(this.UserSettings, this); if (this.Context.IsUpdating) { // Since ServiceConfigurationV4 is a derived type of ServiceConfiguration. So we can deserialize a ServiceConfiguration into a ServiceConfigurationV4. var serviceConfig = this.Context.GetExtendedDesignerData <ServiceConfigurationV4>(); ConfigODataEndpointViewModel.LanguageOption = serviceConfig.LanguageOption; ConfigODataEndpointViewModel.Endpoint = serviceConfig.Endpoint; ConfigODataEndpointViewModel.EdmxVersion = serviceConfig.EdmxVersion; ConfigODataEndpointViewModel.ServiceName = serviceConfig.ServiceName; ConfigODataEndpointViewModel.AcceptAllUntrustedCertificates = serviceConfig.AcceptAllUntrustedCertificates; ConfigODataEndpointViewModel.UseWebProxy = serviceConfig.UseWebProxy; ConfigODataEndpointViewModel.NetworkCredentialsDomain = serviceConfig.NetworkCredentialsDomain; ConfigODataEndpointViewModel.NetworkCredentialsUserName = serviceConfig.NetworkCredentialsUserName; ConfigODataEndpointViewModel.NetworkCredentialsPassword = serviceConfig.NetworkCredentialsPassword; ConfigODataEndpointViewModel.WebProxyNetworkCredentialsDomain = serviceConfig.WebProxyNetworkCredentialsDomain; ConfigODataEndpointViewModel.WebProxyNetworkCredentialsUserName = serviceConfig.WebProxyNetworkCredentialsUserName; ConfigODataEndpointViewModel.WebProxyNetworkCredentialsPassword = serviceConfig.WebProxyNetworkCredentialsPassword; ConfigODataEndpointViewModel.UseNetworkCredentials = serviceConfig.UseNetworkCredentials; ConfigODataEndpointViewModel.WebProxyUri = serviceConfig.WebProxyUri; if (ConfigODataEndpointViewModel.View is ConfigODataEndpoint configODataEndpoint) { configODataEndpoint.IsEnabled = false; } // The Viewmodel should always be filled otherwise if the wizard is completed without visiting this page the generated code becomes wrong AdvancedSettingsViewModel.GeneratedFileNameEnabled = false; // advancedSettings.ReferenceFileName.IsEnabled = false; AdvancedSettingsViewModel.GeneratedFileNamePrefix = serviceConfig.GeneratedFileNamePrefix; AdvancedSettingsViewModel.UseNamespacePrefix = serviceConfig.UseNameSpacePrefix; AdvancedSettingsViewModel.NamespacePrefix = serviceConfig.NamespacePrefix; AdvancedSettingsViewModel.UseDataServiceCollection = serviceConfig.UseDataServiceCollection; AdvancedSettingsViewModel.UseAsyncDataServiceCollection = serviceConfig.UseAsyncDataServiceCollection; AdvancedSettingsViewModel.OperationImportsGenerator = serviceConfig.OperationImportsGenerator; AdvancedSettingsViewModel.SelectOperationImports = serviceConfig.GenerateOperationImports; AdvancedSettingsViewModel.ExcludedOperationImportsNames = serviceConfig.ExcludedOperationImportsNames; if (serviceConfig.EdmxVersion == Common.Constants.EdmxVersion4) { AdvancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; AdvancedSettingsViewModel.GenerateDynamicPropertiesCollection = serviceConfig.GenerateDynamicPropertiesCollection; AdvancedSettingsViewModel.DynamicPropertiesCollectionName = serviceConfig.DynamicPropertiesCollectionName; AdvancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; AdvancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; AdvancedSettingsViewModel.MakeTypesInternal = serviceConfig.MakeTypesInternal; AdvancedSettingsViewModel.IncludeT4FileEnabled = true; } // Restore the advanced settings to UI elements. AdvancedSettingsViewModel.PageEntering += (sender, args) => { if (sender is AdvancedSettingsViewModel advancedSettingsViewModel) { if (advancedSettingsViewModel.View is AdvancedSettings advancedSettings) { advancedSettings.ReferenceFileName.IsEnabled = false; advancedSettingsViewModel.GeneratedFileNamePrefix = serviceConfig.GeneratedFileNamePrefix; advancedSettingsViewModel.UseNamespacePrefix = serviceConfig.UseNameSpacePrefix; advancedSettingsViewModel.NamespacePrefix = serviceConfig.NamespacePrefix; advancedSettingsViewModel.UseDataServiceCollection = serviceConfig.UseDataServiceCollection; advancedSettingsViewModel.UseAsyncDataServiceCollection = serviceConfig.UseAsyncDataServiceCollection; advancedSettingsViewModel.OperationImportsGenerator = serviceConfig.OperationImportsGenerator; advancedSettingsViewModel.SelectOperationImports = serviceConfig.GenerateOperationImports; advancedSettingsViewModel.ExcludedOperationImportsNames = serviceConfig.ExcludedOperationImportsNames; if (serviceConfig.EdmxVersion == Common.Constants.EdmxVersion4) { advancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; advancedSettingsViewModel.GenerateDynamicPropertiesCollection = serviceConfig.GenerateDynamicPropertiesCollection; advancedSettingsViewModel.DynamicPropertiesCollectionName = serviceConfig.DynamicPropertiesCollectionName; advancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; advancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; advancedSettingsViewModel.MakeTypesInternal = serviceConfig.MakeTypesInternal; advancedSettingsViewModel.IncludeT4FileEnabled = true; advancedSettings.IncludeT4File.IsEnabled = true; } if (!advancedSettingsViewModel.SelectOperationImports || UserSettings.LanguageOption != LanguageOption.GenerateCSharpCode) { RemoveOperationImportsSettingsPage(); } else { AddOperationImportsSettingsPage(); } } } }; FunctionImportsViewModel.FunctionImports = serviceConfig.FunctionImports ?? new List <FunctionImportModel>(); FunctionImportsViewModel.OperationImports = serviceConfig.OperationImports ?? new List <OperationImportModel>(); FunctionImportsViewModel.FunctionImportsCount = serviceConfig.FunctionImports?.Count ?? 0; FunctionImportsViewModel.OperationImportsCount = serviceConfig.OperationImports?.Count ?? 0; } AdvancedSettingsViewModel.PageEntering += (sender, args) => { if (sender is AdvancedSettingsViewModel advancedSettingsViewModel) { advancedSettingsViewModel.IncludeExtensionsT4File = AdvancedSettingsViewModel.IncludeExtensionsT4File; advancedSettingsViewModel.IncludeExtensionsT4FileVisibility = ConfigODataEndpointViewModel.EdmxVersion != Common.Constants.EdmxVersion4 ? Visibility.Visible : Visibility.Collapsed; advancedSettingsViewModel.OperationImportsGenerator = AdvancedSettingsViewModel.OperationImportsGenerator; advancedSettingsViewModel.SelectOperationImports = AdvancedSettingsViewModel.SelectOperationImports; advancedSettingsViewModel.IncludeT4FileEnabled = true; if (!advancedSettingsViewModel.SelectOperationImports || UserSettings.LanguageOption != LanguageOption.GenerateCSharpCode) { RemoveOperationImportsSettingsPage(); } else { AddOperationImportsSettingsPage(); } } }; FunctionImportsViewModel.PageEntering += (sender, args) => { if (sender is FunctionImportsViewModel functionImportsViewModel) { if (ConfigODataEndpointViewModel.EdmxVersion == Common.Constants.EdmxVersion4 && (FunctionImportsViewModel.OperationImports == null || !FunctionImportsViewModel.OperationImports.Any() || (AdvancedSettingsViewModel.UseNamespacePrefix && FunctionImportsViewModel.OperationImports.Any(fi => fi.Namespace != AdvancedSettingsViewModel.NamespacePrefix)) || FunctionImportsViewModel.OperationImports.Any(fi => !this.UserSettings.Endpoint.Contains(fi.EndpointUri)))) { FunctionImportsViewModel.OperationImports = OperationImportsHelper.GetOperationsImports( (this.CreateServiceConfiguration() as ServiceConfigurationV4).GetODataEdmModel(), AdvancedSettingsViewModel.UseNamespacePrefix ? AdvancedSettingsViewModel.NamespacePrefix : null, File.Exists(ConfigODataEndpointViewModel.Endpoint) ? ConfigODataEndpointViewModel.Endpoint : ConfigODataEndpointViewModel.Endpoint.Replace("$metadata", string.Empty)); FunctionImportsViewModel.OperationImportsCount = FunctionImportsViewModel.OperationImports?.Count ?? 0; } if (ConfigODataEndpointViewModel.EdmxVersion != Common.Constants.EdmxVersion4 && (FunctionImportsViewModel.FunctionImports == null || !FunctionImportsViewModel.FunctionImports.Any() || (AdvancedSettingsViewModel.UseNamespacePrefix && FunctionImportsViewModel.FunctionImports.Any(fi => fi.Namespace != AdvancedSettingsViewModel.NamespacePrefix)) || FunctionImportsViewModel.FunctionImports.Any(fi => !this.UserSettings.Endpoint.Contains(fi.EndpointUri)))) { FunctionImportsViewModel.FunctionImports = FunctionImportsHelper.GetFunctionImports( this.CreateServiceConfiguration().GetDataEdmModel(), AdvancedSettingsViewModel.UseNamespacePrefix ? AdvancedSettingsViewModel.NamespacePrefix : null, File.Exists(ConfigODataEndpointViewModel.Endpoint) ? ConfigODataEndpointViewModel.Endpoint : ConfigODataEndpointViewModel.Endpoint.Replace("$metadata", string.Empty)); FunctionImportsViewModel.FunctionImportsCount = FunctionImportsViewModel.FunctionImports?.Count ?? 0; } functionImportsViewModel.FunctionImports = FunctionImportsViewModel.FunctionImports; functionImportsViewModel.FunctionImportsCount = functionImportsViewModel.FunctionImports?.Count ?? 0; functionImportsViewModel.OperationImports = FunctionImportsViewModel.OperationImports; functionImportsViewModel.OperationImportsCount = functionImportsViewModel.OperationImports?.Count ?? 0; } }; this.Pages.Add(ConfigODataEndpointViewModel); this.Pages.Add(AdvancedSettingsViewModel); this.IsFinishEnabled = true; }
public ODataConnectedServiceWizard(ConnectedServiceProviderContext context) { this.Context = context; this.UserSettings = UserSettings.Load(context.Logger); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(this.UserSettings, this); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(this.UserSettings); OperationImportsViewModel = new OperationImportsViewModel(); ServiceConfigurationV4 serviceConfig = null; OperationImportsViewModel.PageEntering += ObjectSelectionViewModel_PageEntering; if (this.Context.IsUpdating) { //Since ServiceConfigurationV4 is a derived type of ServiceConfiguration. So we can deserialize a ServiceConfiguration into a ServiceConfigurationV4. serviceConfig = this.Context.GetExtendedDesignerData <ServiceConfigurationV4>(); ConfigODataEndpointViewModel.Endpoint = serviceConfig.Endpoint; ConfigODataEndpointViewModel.EdmxVersion = serviceConfig.EdmxVersion; ConfigODataEndpointViewModel.ServiceName = serviceConfig.ServiceName; ConfigODataEndpointViewModel.CustomHttpHeaders = serviceConfig.CustomHttpHeaders; // The ViewModel should always be filled otherwise if the wizard is completed without visiting this page the generated code becomes wrong AdvancedSettingsViewModel.UseNamespacePrefix = serviceConfig.UseNamespacePrefix; AdvancedSettingsViewModel.NamespacePrefix = serviceConfig.NamespacePrefix; AdvancedSettingsViewModel.UseDataServiceCollection = serviceConfig.UseDataServiceCollection; if (serviceConfig.EdmxVersion == Common.Constants.EdmxVersion4) { AdvancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; AdvancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; AdvancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; AdvancedSettingsViewModel.MakeTypesInternal = serviceConfig.MakeTypesInternal; } ConfigODataEndpointViewModel.PageEntering += (sender, args) => { var configOdataViewModel = sender as ConfigODataEndpointViewModel; if (configOdataViewModel != null) { var configOdataView = configOdataViewModel.View as ConfigODataEndpoint; configOdataView.Endpoint.IsEnabled = false; configOdataView.OpenConnectedServiceJsonFileButton.IsEnabled = false; configOdataView.OpenEndpointFileButton.IsEnabled = !serviceConfig.Endpoint.StartsWith("http"); configOdataView.ServiceName.IsEnabled = false; configOdataViewModel.IncludeCustomHeaders = serviceConfig.IncludeCustomHeaders; configOdataViewModel.IncludeWebProxy = serviceConfig.IncludeWebProxy; configOdataViewModel.WebProxyHost = serviceConfig.WebProxyHost; configOdataViewModel.IncludeWebProxyNetworkCredentials = serviceConfig.IncludeWebProxyNetworkCredentials; configOdataViewModel.WebProxyNetworkCredentialsDomain = serviceConfig.WebProxyNetworkCredentialsDomain; // don't accept any credentials from the restored settings configOdataViewModel.WebProxyNetworkCredentialsUsername = null; configOdataViewModel.WebProxyNetworkCredentialsPassword = null; } }; //Restore the advanced settings to UI elements. AdvancedSettingsViewModel.PageEntering += (sender, args) => { if (sender is AdvancedSettingsViewModel advancedSettingsViewModel) { if (advancedSettingsViewModel.View is AdvancedSettings advancedSettings) { advancedSettingsViewModel.GeneratedFileNamePrefix = serviceConfig.GeneratedFileNamePrefix; advancedSettings.ReferenceFileName.IsEnabled = false; advancedSettingsViewModel.UseNamespacePrefix = serviceConfig.UseNamespacePrefix; advancedSettingsViewModel.NamespacePrefix = serviceConfig.NamespacePrefix; advancedSettingsViewModel.UseDataServiceCollection = serviceConfig.UseDataServiceCollection; advancedSettingsViewModel.GenerateMultipleFiles = serviceConfig.GenerateMultipleFiles; advancedSettings.GenerateMultipleFiles.IsEnabled = false; if (serviceConfig.EdmxVersion == Common.Constants.EdmxVersion4) { advancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; advancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; advancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; advancedSettingsViewModel.MakeTypesInternal = serviceConfig.MakeTypesInternal; advancedSettings.IncludeT4File.IsEnabled = false; } } } }; } this.Pages.Add(ConfigODataEndpointViewModel); this.Pages.Add(OperationImportsViewModel); this.Pages.Add(AdvancedSettingsViewModel); this.IsFinishEnabled = true; }
public void Init() { userSettings = new UserSettings(); serviceWizard = new ODataConnectedServiceWizard(null); configOdataEndPointViewModel = new ConfigODataEndpointViewModel(userSettings, serviceWizard); }
public Wizard(ConnectedServiceProviderContext context) { this.Context = context; this.UserSettings = UserSettings.Load(context.Logger); ConfigODataEndpointViewModel = new ConfigODataEndpointViewModel(this.UserSettings); AdvancedSettingsViewModel = new AdvancedSettingsViewModel(this.UserSettings); if (this.Context.IsUpdating) { //Since ServiceConfigurationV4 is a derived type of ServiceConfiguration. So we can deserialize a ServiceConfiguration into a ServiceConfigurationV4. var serviceConfig = this.Context.GetExtendedDesignerData <ServiceConfigurationV4>(); ConfigODataEndpointViewModel.Endpoint = serviceConfig.Endpoint; ConfigODataEndpointViewModel.EdmxVersion = serviceConfig.EdmxVersion; ConfigODataEndpointViewModel.ServiceName = serviceConfig.ServiceName; ConfigODataEndpointViewModel.UseWebProxy = serviceConfig.UseWebProxy; ConfigODataEndpointViewModel.NetworkCredentialsDomain = serviceConfig.NetworkCredentialsDomain; ConfigODataEndpointViewModel.NetworkCredentialsUserName = serviceConfig.NetworkCredentialsUserName; ConfigODataEndpointViewModel.NetworkCredentialsPassword = serviceConfig.NetworkCredentialsPassword; ConfigODataEndpointViewModel.WebProxyNetworkCredentialsDomain = serviceConfig.WebProxyNetworkCredentialsDomain; ConfigODataEndpointViewModel.WebProxyNetworkCredentialsUserName = serviceConfig.WebProxyNetworkCredentialsUserName; ConfigODataEndpointViewModel.WebProxyNetworkCredentialsPassword = serviceConfig.WebProxyNetworkCredentialsPassword; ConfigODataEndpointViewModel.UseNetworkCredentials = serviceConfig.UseNetworkCredentials; ConfigODataEndpointViewModel.WebProxyUri = serviceConfig.WebProxyUri; if (ConfigODataEndpointViewModel.View is ConfigODataEndpoint configODataEndpoint) { configODataEndpoint.IsEnabled = false; } //Restore the advanced settings to UI elements. AdvancedSettingsViewModel.PageEntering += (sender, args) => { if (sender is AdvancedSettingsViewModel advancedSettingsViewModel) { if (advancedSettingsViewModel.View is AdvancedSettings advancedSettings) { advancedSettings.ReferenceFileName.IsEnabled = false; advancedSettingsViewModel.GeneratedFileName = serviceConfig.GeneratedFileNamePrefix; advancedSettingsViewModel.UseNamespacePrefix = serviceConfig.UseNameSpacePrefix; advancedSettingsViewModel.NamespacePrefix = serviceConfig.NamespacePrefix; advancedSettingsViewModel.UseDataServiceCollection = serviceConfig.UseDataServiceCollection; if (serviceConfig.EdmxVersion == Common.Constants.EdmxVersion4) { advancedSettingsViewModel.IgnoreUnexpectedElementsAndAttributes = serviceConfig.IgnoreUnexpectedElementsAndAttributes; advancedSettingsViewModel.EnableNamingAlias = serviceConfig.EnableNamingAlias; advancedSettingsViewModel.IncludeT4File = serviceConfig.IncludeT4File; advancedSettings.IncludeT4File.IsEnabled = false; } } } }; } AdvancedSettingsViewModel.PageEntering += (sender, args) => { if (sender is AdvancedSettingsViewModel advancedSettingsViewModel) { advancedSettingsViewModel.IncludeExtensionsT4File = ConfigODataEndpointViewModel.EdmxVersion != Common.Constants.EdmxVersion4; advancedSettingsViewModel.IncludeExtensionsT4FileVisibility = ConfigODataEndpointViewModel.EdmxVersion != Common.Constants.EdmxVersion4 ? Visibility.Visible : Visibility.Collapsed; advancedSettingsViewModel.FunctionImportsGenerator = AdvancedSettingsViewModel.FunctionImportsGenerator; advancedSettingsViewModel.GenerateFunctionImports = AdvancedSettingsViewModel.GenerateFunctionImports; } }; this.Pages.Add(ConfigODataEndpointViewModel); this.Pages.Add(AdvancedSettingsViewModel); this.IsFinishEnabled = true; }