private void BtnAddNameSpace_Click(object sender, RoutedEventArgs e) { if (ReplaceNameSpaces.Any(x => x.From == fromNameSpace.Text)) { MessageBox.Show($"{fromNameSpace.Text} exist", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else if (string.IsNullOrEmpty(fromNameSpace.Text) && !chkIsGlobal.IsChecked.GetValueOrDefault()) { MessageBox.Show($"from value cannot be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else if (!string.IsNullOrEmpty(fromNameSpace.Text) && chkIsGlobal.IsChecked.GetValueOrDefault()) { MessageBox.Show($"you cannot set text for global reference replacement, please empty from textbox then try again or uncheck it", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else if (string.IsNullOrEmpty(fromNameSpace.Text) && chkIsGlobal.IsChecked.GetValueOrDefault() && ReplaceNameSpaces.Any(x => x.IsGlobal)) { MessageBox.Show($"you cannot global replacement double time", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } else { ReplaceNameSpaces.Add(new ReplaceNameSpaceInfo() { From = fromNameSpace.Text, To = toNameSpace.Text, IsGlobal = chkIsGlobal.IsChecked.GetValueOrDefault() }); fromNameSpace.Text = ""; toNameSpace.Text = ""; } }
private void btnAddService_Click(object sender, RoutedEventArgs e) { Dispatcher.VerifyAccess(); try { Project project = ((ProjectInfo)LanguageMap.Current.GetActiveProject()).Project; string projectPath = project.FullName; string servicesFolder = Path.Combine(Path.GetDirectoryName(projectPath), "Connected Services"); if (!Directory.Exists(servicesFolder)) { project.ProjectItems.AddFolder("Connected Services"); } Uri uri = null; string serviceNameSpace = txtServiceName.Text.Trim(); string serviceURI = txtServiceAddress.Text.Trim(); if (string.IsNullOrEmpty(serviceNameSpace)) { MessageBox.Show("Please fill your service name", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } else if (!Uri.TryCreate(serviceURI, UriKind.Absolute, out uri)) { MessageBox.Show("Service address is not true", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } string servicePath = Path.Combine(servicesFolder, Path.GetFileNameWithoutExtension(serviceNameSpace)); if (!Directory.Exists(servicePath)) { Directory.CreateDirectory(servicePath); } AddReferenceConfigInfo config = new AddReferenceConfigInfo { ServiceUrl = serviceURI, ServiceNameSpace = serviceNameSpace, LanguageType = cboLanguage.SelectedIndex, ServiceType = cboServiceType.SelectedIndex, IsGenerateAsyncMethods = chkAsyncMethods.IsChecked.Value, IsJustGenerateServices = chkJustServices.IsChecked.Value, IsAutomaticSyncAndAsyncDetection = rdoIsAutomaticDetection.IsChecked.Value, ReplaceNameSpaces = ReplaceNameSpaces.ToList(), SkipAssemblies = SkipAssemblies.ToList(), CustomNameSpaces = customNameSpaces.Text }; string fullFilePath = LanguageMap.Current.DownloadService(servicePath, config); string signalGoSettingPath = Path.Combine(servicePath, "setting.signalgo"); File.WriteAllText(signalGoSettingPath, JsonConvert.SerializeObject(config), Encoding.UTF8); if (!string.IsNullOrEmpty(fullFilePath)) { project.ProjectItems.AddFromFile(fullFilePath); } FinishedAction?.Invoke(); MessageBox.Show($"Service {serviceNameSpace} generated", "Success", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void BtnRemoveReplaceNameSpaces_Click(object sender, RoutedEventArgs e) { ReplaceNameSpaces.Remove((ReplaceNameSpaceInfo)((Button)sender).DataContext); }