public void OnMenuChangeAddServiceReference(object sender, EventArgs e)
        {
            try
            {
                Store store = this.CurrentDocView.CurrentDiagram.Store;
                Proxy proxy = DomainModelHelper.GetSelectedElement(this.ServiceProvider) as Proxy;

                if (proxy != null &&
                    !string.IsNullOrWhiteSpace(proxy.ClientApplication.ImplementationProject) &&
                    proxy.ClientApplication.ImplementationTechnology != null)
                {
                    IVsSolution solution = this.ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
                    using (HierarchyNode projectNode = new HierarchyNode(solution, proxy.ClientApplication.ImplementationProject))
                    {
                        if (projectNode != null)
                        {
                            IVsAddWebReferenceResult result = VsShellDialogs.AddWebReferenceDialog(this.ServiceProvider, null, projectNode);
                            if (result != null)
                            {
                                result.Save();  // IVsWCFReferenceGroup refGropup = (IVsWCFReferenceGroup)result.Save()
                            }
                        }
                    }
                }
            }
            catch (Exception error)
            {
                Logger.Write(error);
            }
        }
Пример #2
0
        // Add a service reference to the given project.
        public static IVsAddWebReferenceResult AddWebReferenceDialog(
            IServiceProvider serviceProvider,
            string title,
            HierarchyNode proxyProject)
        {
            Guard.ArgumentNotNull(serviceProvider, "serviceProvider");
            Guard.ArgumentNotNull(proxyProject, "proxyProject");

            if (!proxyProject.GetProperty <Boolean>((int)__VSHPROPID3.VSHPROPID_ServiceReferenceSupported))
            {
                throw new NotSupportedException(Properties.Resources.ServiceReferenceSupported);
            }

            IVsAddWebReferenceDlg3 awrdlg           = serviceProvider.GetService(typeof(SVsAddWebReferenceDlg3)) as IVsAddWebReferenceDlg3;
            IVsDiscoveryService    discoveryService = serviceProvider.GetService(typeof(SVsDiscoveryService)) as IVsDiscoveryService;
            IDiscoverySession      discoverySession = null;

            if (discoveryService != null)
            {
                discoveryService.CreateDiscoverySession(out discoverySession);
            }

            IVsAddWebReferenceResult addWebReferenceResult = null;

            int cancelled = 1;

            if (awrdlg != null)
            {
                awrdlg.ShowAddWebReferenceDialog(
                    proxyProject.Hierarchy,
                    discoverySession,
                    ServiceReferenceType.SRT_WCFReference | ServiceReferenceType.SRT_ASMXReference,
                    title,
                    null,
                    null,
                    out addWebReferenceResult,
                    out cancelled);
            }

            if (addWebReferenceResult != null && cancelled == 0)
            {
                return(addWebReferenceResult);
            }
            else
            {
                return(null);
            }
        }