public void NewWebReference() { // Get the project and project folder DotNetProject project = CurrentNode.GetParentDataItem(typeof(DotNetProject), true) as DotNetProject; // Check and switch the runtime environment for the current project if (project.TargetFramework.Id == TargetFrameworkMoniker.NET_1_1) { string question = "The current runtime environment for your project is set to version 1.0."; question += "Web Service is not supported in this version."; question += "Do you want switch the runtime environment for this project version 2.0 ?"; AlertButton switchButton = new AlertButton("_Switch to .NET2"); if (MessageService.AskQuestion(question, AlertButton.Cancel, switchButton) == switchButton) { project.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(TargetFrameworkMoniker.NET_2_0); } else { return; } } WebReferenceDialog dialog = new WebReferenceDialog(project); dialog.NamespacePrefix = project.DefaultNamespace; try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok) { return; } var wcfResult = dialog.SelectedService as WCF.WebServiceDiscoveryResultWCF; if (ConfigurationDialog.IsSupported() && (wcfResult != null)) { var options = CreateClientOptions(); if (options == null) { return; } wcfResult.InitialClientOptions = options; } dialog.SelectedService.GenerateFiles(project, dialog.Namespace, dialog.ReferenceName); IdeApp.ProjectOperations.Save(project); } catch (Exception exception) { MessageService.ShowException(exception); } finally { dialog.Destroy(); } }
public void Configure() { var item = (WebReferenceItem)CurrentNode.DataItem; if (!ConfigurationDialog.IsSupported(item)) { return; } WCF.ReferenceGroup refgroup; WCF.ClientOptions options; try { refgroup = WCF.ReferenceGroup.Read(item.MapFile.FilePath); if (refgroup == null || refgroup.ClientOptions == null) { return; } options = refgroup.ClientOptions; } catch { return; } var dialog = new ConfigurationDialog(options); try { if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok) { return; } if (!dialog.Modified) { return; } refgroup.Save(item.MapFile.FilePath); UpdateReferences(new [] { item }); } catch (Exception exception) { MessageService.ShowException(exception); } finally { dialog.Destroy(); } }
void CanConfigureWebReferences(CommandInfo ci) { var item = (WebReferenceItem)CurrentNode.DataItem; ci.Enabled = ConfigurationDialog.IsSupported(item); }