IVsAddWebReferenceDlg3::ShowDiscoveredServicesInCurrentDialog Method (Int32, array<String^>^, array<String^>^, String^, String^)
Visual Studio 2015
Displays a list of Windows Communication Foundation (WCF) services in an Add Service Reference dialog box.
Assembly: Microsoft.VisualStudio.WCFReference.Interop (in Microsoft.VisualStudio.WCFReference.Interop.dll)
void ShowDiscoveredServicesInCurrentDialog( int cItems, array<String^>^ ServiceUrls, array<String^>^ ServiceDisplayNames, String^ pszStatusText, String^ pszErrorText )
Parameters
- cItems
-
Type:
System::Int32
A Long that contains the number of items to display.
- ServiceUrls
-
Type:
array<System::String^>^
A String array that contains the URL addresses for the services.
- ServiceDisplayNames
-
Type:
array<System::String^>^
A String array that contains the names of the services.
- pszStatusText
-
Type:
System::String^
A String that contains the status text. Can be Null for default status.
- pszErrorText
-
Type:
System::String^
A String that contains the error text. Null if there were no errors.
Use this method when you extend the Discover button in the Add Service Reference dialog box to display services returned by your custom discovery code.
The following example demonstrates how to display services in the Add Service Reference dialog box.
// Ask Visual Studio what window to use as the dialog's owner.
IUIService uiservice = GetService(typeof(IUIService)) as IUIService;
IWin32Window ownerWindow = null;
if (uiservice != null)
{
ownerWindow = uiservice.GetDialogOwnerWindow();
}
// Display the form and get the user input.
ServiceInfo[] services;
using (SearchForm form = new SearchForm())
{
services = form.DiscoverServices(ownerWindow, uiservice);
}
if (services == null)
{
// The user canceled the dialog.
addWebReferenceDlg3.ShowDiscoveredServicesInCurrentDialog( 0, new string[] { }, new string[] { },Properties.Resources.SearchCanceled, // status text
null // Null means no errors occurred
);
return;
}
else
{
// Build up an array of URLs and an array of display names.
string[] serviceUrls = new string[services.Length];
string[] serviceDisplayNames = new string[services.Length];
for (int i = 0; i < services.Length; ++i)
{
serviceUrls[i] = services[i].Uri.AbsoluteUri;
serviceDisplayNames[i] = services[i].DisplayName;
}
// And tell the Add Service Reference dialog to display them.
addWebReferenceDlg3.ShowDiscoveredServicesInCurrentDialog(services.Length, serviceUrls, serviceDisplayNames,null, // Null means to use the default status text.
null // Null means no errors occurred.
);
}
Show: