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();
            }
        }
Beispiel #2
0
        public void Configure()
        {
            var item = (WebReferenceItem)CurrentNode.DataItem;

            if (!WCFConfigWidget.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 WebReferenceDialog(item, 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) {
                LoggingService.LogInternalError(exception);
            } finally {
                dialog.Destroy();
                dialog.Dispose();
            }
        }
        public async void NewWebReference()
        {
            // Get the project and project folder
            var 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 msg1     = GettextCatalog.GetString("The current runtime environment for your project is set to version 1.0.");
                string msg2     = GettextCatalog.GetString("Web Service is not supported in this version.");
                string msg3     = GettextCatalog.GetString("Do you want switch the runtime environment for this project version 2.0?");
                string question = $"{msg1} {msg2} {msg3}";

                var switchButton = new AlertButton(GettextCatalog.GetString("_Switch to .NET 2.0"));
                if (MessageService.AskQuestion(question, AlertButton.Cancel, switchButton) == switchButton)
                {
                    project.TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework(TargetFrameworkMoniker.NET_2_0);
                }
                else
                {
                    return;
                }
            }

            var dialog = new WebReferenceDialog(project);

            dialog.NamespacePrefix = project.DefaultNamespace;

            try {
                if (MessageService.RunCustomDialog(dialog) != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                await dialog.SelectedService.GenerateFiles(project, dialog.Namespace, dialog.ReferenceName);

                await IdeApp.ProjectOperations.SaveAsync(project);
            } catch (Exception exception) {
                MessageService.ShowError(GettextCatalog.GetString("The web reference could not be added"), exception);
            } finally {
                dialog.Destroy();
                dialog.Dispose();
            }
        }
        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 == "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("2.0");
                }
                else
                {
                    return;
                }
            }

            WebReferenceDialog dialog = new WebReferenceDialog(project);

            dialog.NamespacePrefix = project.Name;

            try {
                if (MessageService.RunCustomDialog(dialog) == (int)Gtk.ResponseType.Ok)
                {
                    dialog.SelectedService.GenerateFiles(project, dialog.Namespace, dialog.ReferenceName);
                    IdeApp.ProjectOperations.Save(project);
                }
            }
            catch (Exception exception) {
                MessageService.ShowException(exception);
            } finally {
                dialog.Destroy();
            }
        }