Browse Source

Store recently used service reference urls in SharpDevelop properties instead of using the browser's most recently used urls.

pull/6/merge
Matt Ward 14 years ago
parent
commit
4e050511e1
  1. 1
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  2. 28
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceViewModel.cs
  3. 54
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceUrlHistory.cs
  4. 35
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs
  5. 1
      src/Main/Base/Test/ServiceReferences/ServiceReferenceGeneratorTests.cs

1
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -290,6 +290,7 @@ @@ -290,6 +290,7 @@
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\ServiceReferenceMapFileProjectItem.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\ServiceReferenceMapGenerator.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\ServiceReferenceProxyGenerator.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\ServiceReferenceUrlHistory.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\SvcUtilCommandLine.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\SvcUtilMessageView.cs" />
<Compile Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference\SvcUtilPath.cs" />

28
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/AddServiceReferenceViewModel.cs

@ -19,12 +19,6 @@ using ICSharpCode.SharpDevelop.Project; @@ -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 @@ -39,13 +33,13 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
ObservableCollection<ImageAndDescription> twoValues;
List<string> mruServices = new List<string>();
ServiceReferenceUrlHistory urlHistory = new ServiceReferenceUrlHistory();
string selectedService;
IProject project;
ServiceReferenceGenerator serviceGenerator;
List<CheckableAssemblyReference> assemblyReferences;
List<ServiceItem> items = new List <ServiceItem>();
List<ServiceItem> items = new List<ServiceItem>();
ServiceItem myItem;
Uri discoveryUri;
@ -64,9 +58,6 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -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<ImageAndDescription>();
@ -223,12 +214,21 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -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");
}
/// <summary>
/// Gets the namespace to be used with the generated web reference code.
/// </summary>
@ -256,11 +256,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference @@ -256,11 +256,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference
public string HeadLine { get; set; }
public List<string> MruServices {
get { return mruServices; }
set {
mruServices = value;
base.RaisePropertyChanged(() => MruServices);
}
get { return urlHistory.Urls; }
}
public string SelectedService {

54
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReference/ServiceReferenceUrlHistory.cs

@ -0,0 +1,54 @@ @@ -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<string>();
ReadSavedServiceReferenceUrls();
}
void ReadSavedServiceReferenceUrls()
{
Urls.AddRange(PropertyService.Get(ServiceReferencePropertyName, new string[0]));
}
public List<string> 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));
}
}
}

35
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs

@ -3,43 +3,13 @@ @@ -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
{
/// <summary>
/// Description of ServiceReferenceHelper.
/// </summary>
internal class ServiceReferenceHelper
internal static 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 (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 @@ -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 @@ -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 @@ -78,6 +46,5 @@ namespace ICSharpCode.SharpDevelop.Gui
}
return String.Empty;
}
}
}

1
src/Main/Base/Test/ServiceReferences/ServiceReferenceGeneratorTests.cs

@ -123,7 +123,6 @@ namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences @@ -123,7 +123,6 @@ namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences
IProject dummyProject = MockRepository.GenerateStub<IProject>();
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;

Loading…
Cancel
Save