22 changed files with 552 additions and 16 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class ClientOptions |
||||
{ |
||||
public ClientOptions() |
||||
{ |
||||
EnableDataBinding = true; |
||||
GenerateSerializableTypes = true; |
||||
Serializer = "Auto"; |
||||
UseSerializerForFaults = true; |
||||
ReferenceAllAssemblies = true; |
||||
} |
||||
|
||||
public bool GenerateAsynchronousMethods { get; set; } |
||||
public bool EnableDataBinding { get; set; } |
||||
public bool ImportXmlTypes { get; set; } |
||||
public bool GenerateInternalTypes { get; set; } |
||||
public bool GenerateMessageContracts { get; set; } |
||||
public bool GenerateSerializableTypes { get; set; } |
||||
public string Serializer { get; set; } |
||||
public bool UseSerializerForFaults { get; set; } |
||||
public bool ReferenceAllAssemblies { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public interface IServiceReferenceFileGenerator : IServiceReferenceProxyGenerator, IServiceReferenceMapGenerator |
||||
{ |
||||
} |
||||
} |
||||
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public interface IServiceReferenceMapGenerator |
||||
{ |
||||
void GenerateServiceReferenceMapFile(ServiceReferenceMapFile mapFile); |
||||
} |
||||
} |
||||
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class MetadataFile |
||||
{ |
||||
public MetadataFile() |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// 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.Xml.Serialization; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class MetadataSource |
||||
{ |
||||
public MetadataSource() |
||||
{ |
||||
} |
||||
|
||||
public MetadataSource(string url) |
||||
{ |
||||
Address = url; |
||||
Protocol = "http"; |
||||
} |
||||
|
||||
[XmlAttribute] |
||||
public string Address { get; set; } |
||||
|
||||
[XmlAttribute] |
||||
public string Protocol { get; set; } |
||||
|
||||
[XmlAttribute] |
||||
public string SourceId { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// 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.ServiceModel.Description; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class ServiceReferenceFileGenerator : IServiceReferenceFileGenerator |
||||
{ |
||||
IServiceReferenceProxyGenerator proxyGenerator; |
||||
IServiceReferenceMapGenerator mapGenerator; |
||||
|
||||
public ServiceReferenceFileGenerator(ICodeDomProvider codeDomProvider) |
||||
: this( |
||||
new ServiceReferenceProxyGenerator(codeDomProvider), |
||||
new ServiceReferenceMapGenerator()) |
||||
{ |
||||
} |
||||
|
||||
public ServiceReferenceFileGenerator( |
||||
IServiceReferenceProxyGenerator proxyGenerator, |
||||
IServiceReferenceMapGenerator mapGenerator) |
||||
{ |
||||
this.proxyGenerator = proxyGenerator; |
||||
this.mapGenerator = mapGenerator; |
||||
} |
||||
|
||||
public string ServiceReferenceNamespace { |
||||
get { return proxyGenerator.ServiceReferenceNamespace; } |
||||
set { proxyGenerator.ServiceReferenceNamespace = value; } |
||||
} |
||||
|
||||
public void GenerateProxyFile(MetadataSet metadata, string proxyFileName) |
||||
{ |
||||
proxyGenerator.GenerateProxyFile(metadata, proxyFileName); |
||||
} |
||||
|
||||
public void GenerateServiceReferenceMapFile(ServiceReferenceMapFile mapFile) |
||||
{ |
||||
mapGenerator.GenerateServiceReferenceMapFile(mapFile); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
// 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.Xml.Serialization; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
[XmlRoot(ElementName = "ReferenceGroup", Namespace = "urn:schemas-microsoft-com:xml-wcfservicemap")] |
||||
public class ServiceReferenceMapFile |
||||
{ |
||||
ClientOptions clientOptions = new ClientOptions(); |
||||
List<MetadataSource> metadataSources = new List<MetadataSource>(); |
||||
List<MetadataFile> metadata = new List<MetadataFile>(); |
||||
|
||||
public ServiceReferenceMapFile() |
||||
{ |
||||
ID = Guid.NewGuid().ToString(); |
||||
} |
||||
|
||||
public ServiceReferenceMapFile(ServiceReferenceMapFileName fileName) |
||||
: this() |
||||
{ |
||||
FileName = fileName.Path; |
||||
} |
||||
|
||||
public override bool Equals(object obj) |
||||
{ |
||||
var rhs = obj as ServiceReferenceMapFile; |
||||
return FileName == rhs.FileName; |
||||
} |
||||
|
||||
public override int GetHashCode() |
||||
{ |
||||
return base.GetHashCode(); |
||||
} |
||||
|
||||
public static ServiceReferenceMapFile CreateMapFileWithUrl(string url) |
||||
{ |
||||
var mapFile = new ServiceReferenceMapFile(); |
||||
mapFile.AddMetadataSourceForUrl(url); |
||||
return mapFile; |
||||
} |
||||
|
||||
public void AddMetadataSourceForUrl(string url) |
||||
{ |
||||
var metadataSource = new MetadataSource(url) { SourceId = "1" }; |
||||
metadataSources.Add(metadataSource); |
||||
} |
||||
|
||||
[XmlIgnoreAttribute] |
||||
public string FileName { get; set; } |
||||
|
||||
[XmlAttribute] |
||||
public string ID { get; set; } |
||||
|
||||
public ClientOptions ClientOptions { |
||||
get { return clientOptions; } |
||||
set { clientOptions = value; } |
||||
} |
||||
|
||||
public List<MetadataSource> MetadataSources { |
||||
get { return metadataSources; } |
||||
} |
||||
|
||||
public List<MetadataFile> Metadata { |
||||
get { return metadata; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
// 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 IO = System.IO; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class ServiceReferenceMapFileName |
||||
{ |
||||
string path; |
||||
|
||||
public ServiceReferenceMapFileName(string serviceReferencesFolder, string serviceName) |
||||
{ |
||||
path = IO.Path.Combine(serviceReferencesFolder, serviceName, "Reference.svcmap"); |
||||
} |
||||
|
||||
public string Path { |
||||
get { return path; } |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
// 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 ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class ServiceReferenceMapFileProjectItem : FileProjectItem |
||||
{ |
||||
public ServiceReferenceMapFileProjectItem( |
||||
IProject project, |
||||
string fileName) |
||||
: base(project, ItemType.None) |
||||
{ |
||||
this.FileName = fileName; |
||||
AddMetadata(); |
||||
} |
||||
|
||||
void AddMetadata() |
||||
{ |
||||
SetMetadata("LastGenOutput", "Reference.cs"); |
||||
SetMetadata("Generator", "WCF Proxy Generator"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// 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.IO; |
||||
using System.Xml.Serialization; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference |
||||
{ |
||||
public class ServiceReferenceMapGenerator : IServiceReferenceMapGenerator |
||||
{ |
||||
public void GenerateServiceReferenceMapFile(ServiceReferenceMapFile mapFile) |
||||
{ |
||||
var writer = new StreamWriter(mapFile.FileName); |
||||
GenerateServiceReferenceMapFile(writer, mapFile); |
||||
} |
||||
|
||||
public void GenerateServiceReferenceMapFile(TextWriter textWriter, ServiceReferenceMapFile mapFile) |
||||
{ |
||||
var serializer = new XmlSerializer(typeof(ServiceReferenceMapFile)); |
||||
serializer.Serialize(textWriter, mapFile); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
// 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.IO; |
||||
using System.Text; |
||||
|
||||
using ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences |
||||
{ |
||||
[TestFixture] |
||||
public class ServiceReferenceMapFileGeneratorTests |
||||
{ |
||||
ServiceReferenceMapGenerator generator; |
||||
|
||||
void CreateFileGenerator() |
||||
{ |
||||
generator = new ServiceReferenceMapGenerator(); |
||||
} |
||||
|
||||
string GenerateMapFile(ServiceReferenceMapFile mapFile) |
||||
{ |
||||
var output = new StringBuilder(); |
||||
var writer = new StringWriter(output); |
||||
|
||||
generator.GenerateServiceReferenceMapFile(writer, mapFile); |
||||
|
||||
return output.ToString(); |
||||
} |
||||
|
||||
ServiceReferenceMapFile CreateServiceReferenceMapFileWithUrl(string url) |
||||
{ |
||||
return ServiceReferenceMapFile.CreateMapFileWithUrl(url); |
||||
} |
||||
|
||||
[Test] |
||||
public void GenerateServiceReferenceMapFile_MapFileWrittenToStringWriter_SerialisesReferenceGroup() |
||||
{ |
||||
CreateFileGenerator(); |
||||
ServiceReferenceMapFile mapFile = CreateServiceReferenceMapFileWithUrl("http://localhost/MyService1.svc"); |
||||
mapFile.ID = "a606bbd6-26e5-4025-a25e-b8c262422f2a"; |
||||
string output = GenerateMapFile(mapFile); |
||||
|
||||
string expectedOutput = |
||||
@"<?xml version=""1.0"" encoding=""utf-16""?>
|
||||
<ReferenceGroup xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" ID=""a606bbd6-26e5-4025-a25e-b8c262422f2a"" xmlns=""urn:schemas-microsoft-com:xml-wcfservicemap"">
|
||||
<ClientOptions> |
||||
<GenerateAsynchronousMethods>false</GenerateAsynchronousMethods> |
||||
<EnableDataBinding>true</EnableDataBinding> |
||||
<ImportXmlTypes>false</ImportXmlTypes> |
||||
<GenerateInternalTypes>false</GenerateInternalTypes> |
||||
<GenerateMessageContracts>false</GenerateMessageContracts> |
||||
<GenerateSerializableTypes>true</GenerateSerializableTypes> |
||||
<Serializer>Auto</Serializer> |
||||
<UseSerializerForFaults>true</UseSerializerForFaults> |
||||
<ReferenceAllAssemblies>true</ReferenceAllAssemblies> |
||||
</ClientOptions> |
||||
<MetadataSources> |
||||
<MetadataSource Address=""http://localhost/MyService1.svc"" Protocol=""http"" SourceId=""1"" />
|
||||
</MetadataSources> |
||||
<Metadata /> |
||||
</ReferenceGroup>";
|
||||
|
||||
Assert.AreEqual(expectedOutput, output); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
// 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 ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences |
||||
{ |
||||
[TestFixture] |
||||
public class ServiceReferenceMapFileTests |
||||
{ |
||||
ServiceReferenceMapFile lhs; |
||||
ServiceReferenceMapFile rhs; |
||||
|
||||
void CreateMapFilesToCompare() |
||||
{ |
||||
lhs = new ServiceReferenceMapFile(); |
||||
rhs = new ServiceReferenceMapFile(); |
||||
} |
||||
|
||||
void AssertFilesAreEqual() |
||||
{ |
||||
bool result = AreFilesEqual(); |
||||
Assert.IsTrue(result); |
||||
} |
||||
|
||||
bool AreFilesEqual() |
||||
{ |
||||
return lhs.Equals(rhs); |
||||
} |
||||
|
||||
void AssertFilesAreNotEqual() |
||||
{ |
||||
bool result = AreFilesEqual(); |
||||
Assert.IsFalse(result); |
||||
} |
||||
|
||||
[Test] |
||||
public void Equals_FilesAreSame_ReturnsTrue() |
||||
{ |
||||
CreateMapFilesToCompare(); |
||||
|
||||
AssertFilesAreEqual(); |
||||
} |
||||
|
||||
[Test] |
||||
public void Equals_FilesHaveDifferentFileNames_ReturnsFalse() |
||||
{ |
||||
CreateMapFilesToCompare(); |
||||
lhs.FileName = "a"; |
||||
rhs.FileName = "b"; |
||||
|
||||
AssertFilesAreNotEqual(); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue