This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
/
ServiceReferenceHelper.cs
76 lines (67 loc) · 1.78 KB
/
ServiceReferenceHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 24.10.2011
* Time: 20:39
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Web.Services.Description;
using System.Web.Services.Discovery;
using Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// Description of ServiceReferenceHelper.
/// </summary>
internal class ServiceReferenceHelper
{
private ServiceReferenceHelper()
{
}
public static List <string> AddMruList()
{
var list = new List<string>();
try {
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs");
if (key != null) {
foreach (string name in key.GetValueNames()) {
list.Add ((string)key.GetValue(name));
}
}
} catch (Exception)
{
};
return list;
}
public static ServiceDescriptionCollection GetServiceDescriptions(DiscoveryClientProtocol protocol)
{
ServiceDescriptionCollection services = new ServiceDescriptionCollection();
protocol.ResolveOneLevel();
foreach (DictionaryEntry entry in protocol.References) {
ContractReference contractRef = entry.Value as ContractReference;
if (contractRef != null) {
services.Add(contractRef.Contract);
}
}
return services;
}
public static string GetServiceName(ServiceDescription description)
{
if (description.Name != null) {
return description.Name;
} else if (description.RetrievalUrl != null) {
Uri uri = new Uri(description.RetrievalUrl);
if (uri.Segments.Length > 0) {
return uri.Segments[uri.Segments.Length - 1];
} else {
return uri.Host;
}
}
return String.Empty;
}
}
}