diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
index af0ef49e4b..cc17ed5a4e 100644
--- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
+++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
@@ -290,6 +290,7 @@
+
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceViewModel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceViewModel.cs
index 56a65d1bbc..604b12b38f 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceViewModel.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceViewModel.cs
@@ -19,12 +19,6 @@ using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Commands;
using ICSharpCode.SharpDevelop.Widgets;
-//using ICSharpCode.Core;
-
-
-
-
-
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
{
public class AddServiceReferenceViewModel : ViewModelBase
@@ -39,13 +33,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
ObservableCollection twoValues;
- List mruServices = new List();
+ ServiceReferenceUrlHistory urlHistory = new ServiceReferenceUrlHistory();
string selectedService;
IProject project;
ServiceReferenceGenerator serviceGenerator;
List assemblyReferences;
- List items = new List ();
+ List items = new List();
ServiceItem myItem;
Uri discoveryUri;
@@ -64,9 +58,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
this.assemblyReferences = serviceGenerator.GetCheckableAssemblyReferences().ToList();
HeadLine = header;
- MruServices = ServiceReferenceHelper.AddMruList();
- SelectedService = MruServices.FirstOrDefault();
-
GoCommand = new RelayCommand(ExecuteGo, CanExecuteGo);
AdvancedDialogCommand = new RelayCommand(ExecuteAdvancedDialogCommand, CanExecuteAdvancedDialogCommand);
TwoValues = new ObservableCollection();
@@ -223,12 +214,21 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
"{0} service(s) found at address {1}",
serviceDescriptionCollection.Count,
discoveryUri);
+ if (serviceDescriptionCollection.Count > 0) {
+ AddUrlToHistory(discoveryUri);
+ }
DefaultNameSpace = GetDefaultNamespace();
FillItems(serviceDescriptionCollection);
string referenceName = ServiceReferenceHelper.GetReferenceName(discoveryUri);
}
}
+ void AddUrlToHistory(Uri discoveryUri)
+ {
+ urlHistory.AddUrl(discoveryUri);
+ RaisePropertyChanged("MruServices");
+ }
+
///
/// Gets the namespace to be used with the generated web reference code.
///
@@ -256,11 +256,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
public string HeadLine { get; set; }
public List MruServices {
- get { return mruServices; }
- set {
- mruServices = value;
- base.RaisePropertyChanged(() => MruServices);
- }
+ get { return urlHistory.Urls; }
}
public string SelectedService {
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceUrlHistory.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceUrlHistory.cs
new file mode 100644
index 0000000000..5d3ee15c4d
--- /dev/null
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceUrlHistory.cs
@@ -0,0 +1,54 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using ICSharpCode.Core;
+
+namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
+{
+ public class ServiceReferenceUrlHistory
+ {
+ public const int MaxItems = 10;
+
+ const string ServiceReferencePropertyName = "ServiceReference.Urls";
+
+ public ServiceReferenceUrlHistory()
+ {
+ Urls = new List();
+ ReadSavedServiceReferenceUrls();
+ }
+
+ void ReadSavedServiceReferenceUrls()
+ {
+ Urls.AddRange(PropertyService.Get(ServiceReferencePropertyName, new string[0]));
+ }
+
+ public List Urls { get; private set; }
+
+ public void AddUrl(Uri uri)
+ {
+ AddUrl(uri.ToString());
+ }
+
+ public void AddUrl(string url)
+ {
+ if (Contains(url)) {
+ return;
+ }
+
+ if (Urls.Count >= MaxItems) {
+ Urls.RemoveAt(Urls.Count - 1);
+ }
+ Urls.Insert(0, url);
+ PropertyService.Set(ServiceReferencePropertyName, Urls.ToArray());
+ }
+
+ bool Contains(string url)
+ {
+ return Urls.Any(item => String.Equals(item, url, StringComparison.OrdinalIgnoreCase));
+ }
+ }
+}
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs
index 01c5c4a084..f7af979376 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs
@@ -3,43 +3,13 @@
using System;
using System.Collections;
-using System.Collections.Generic;
-using System.IO;
-using System.Security;
using System.Web.Services.Description;
using System.Web.Services.Discovery;
-using Microsoft.Win32;
-
namespace ICSharpCode.SharpDevelop.Gui
{
- ///
- /// Description of ServiceReferenceHelper.
- ///
- internal class ServiceReferenceHelper
+ internal static class ServiceReferenceHelper
{
- private ServiceReferenceHelper()
- {
- }
-
- public static List AddMruList()
- {
- var list = new List();
- 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 (SecurityException) {
- } catch (UnauthorizedAccessException) {
- } catch (IOException) {
- };
- return list;
- }
-
-
public static ServiceDescriptionCollection GetServiceDescriptions(DiscoveryClientProtocol protocol)
{
ServiceDescriptionCollection services = new ServiceDescriptionCollection();
@@ -54,7 +24,6 @@ namespace ICSharpCode.SharpDevelop.Gui
return services;
}
-
public static string GetServiceName(ServiceDescription description)
{
if (description.Name != null) {
@@ -70,7 +39,6 @@ namespace ICSharpCode.SharpDevelop.Gui
return String.Empty;
}
-
public static string GetReferenceName(Uri uri)
{
if (uri != null) {
@@ -78,6 +46,5 @@ namespace ICSharpCode.SharpDevelop.Gui
}
return String.Empty;
}
-
}
}
diff --git a/src/Main/Base/Test/ServiceReferences/ServiceReferenceGeneratorTests.cs b/src/Main/Base/Test/ServiceReferences/ServiceReferenceGeneratorTests.cs
index a4b2e1c5e4..e9a5fbdc83 100644
--- a/src/Main/Base/Test/ServiceReferences/ServiceReferenceGeneratorTests.cs
+++ b/src/Main/Base/Test/ServiceReferences/ServiceReferenceGeneratorTests.cs
@@ -123,7 +123,6 @@ namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences
IProject dummyProject = MockRepository.GenerateStub();
dummyProject.Stub(p => p.SyncRoot).Return(new object());
var projectItem = new ReferenceProjectItem(dummyProject, reference);
- Console.WriteLine(projectItem.Include);
projectItem.FileName = fileName;
projectReferences.Add(projectItem);
return projectItem;