Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from 52North/develop
Browse files Browse the repository at this point in the history
Release version 1.0.3
  • Loading branch information
Mehigh17 authored Aug 29, 2019
2 parents 4c96b32 + aff4604 commit 7099d7e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/Wps/Wps.Client.Tests/ModelSerializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void SerializeValueRange_ValidRangeGiven_ShouldPass()
[Fact]
public void SerializeDataInput_ValidInputGiven_ShouldPass()
{
const string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?><Input id=""test-id"" xmlns=""http://www.opengis.net/wps/2.0""><wps:Data xmlns:wps=""http://www.opengis.net/wps/2.0""><LiteralValue xmlns=""http://www.opengis.net/wps/2.0"">105</LiteralValue></wps:Data><wps:Reference xmlns:ows=""http://www.opengis.net/ows/2.0"" xmlns:xli=""http://www.w3.org/1999/xlink"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xli:href=""test"" schema=""test-schema"" xmlns:wps=""http://www.opengis.net/wps/2.0"" /></Input>";
const string expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?><Input id=""test-id"" xmlns=""http://www.opengis.net/wps/2.0""><wps:Data mimeType=""test mime type"" encoding=""test encoding"" schema=""test schema"" xmlns:wps=""http://www.opengis.net/wps/2.0"">test string</wps:Data><wps:Reference xmlns:ows=""http://www.opengis.net/ows/2.0"" xmlns:xli=""http://www.w3.org/1999/xlink"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xli:href=""test"" schema=""test-schema"" xmlns:wps=""http://www.opengis.net/wps/2.0"" /></Input>";

// Remove white spaces and new line characters for XML comparison.
var trimmedExpectedXml = Regex.Replace(expectedXml, @"\s+", string.Empty);
Expand All @@ -150,10 +150,14 @@ public void SerializeDataInput_ValidInputGiven_ShouldPass()
Href = "test",
Schema = "test-schema"
},
Data = new LiteralDataValue
{
Value = 105.ToString(CultureInfo.InvariantCulture)
}
//Data = new LiteralDataValue
//{
// Value = 105.ToString(CultureInfo.InvariantCulture)
//},
Data = "test string",
MimeType = "test mime type",
Schema = "test schema",
Encoding = "test encoding"
};

var resultXml = _serializer.Serialize(dataInput);
Expand Down
1 change: 0 additions & 1 deletion src/Wps/Wps.Client.Tests/WpsClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
using Wps.Client.Models.Requests;
using Wps.Client.Services;
using Xunit;
using Xunit.Sdk;

namespace Wps.Client.Tests
{
Expand Down
19 changes: 18 additions & 1 deletion src/Wps/Wps.Client/Models/Execution/DataInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@

namespace Wps.Client.Models.Execution
{
/// <summary>
/// The data input model used for the execution requests. If the data is of type <see cref="string"/> it will be copied inside the data tags as is with no further serialization.
/// </summary>
[XmlRoot("Input", Namespace = ModelNamespaces.Wps)]
public class DataInput : IXmlSerializable
{

public string MimeType { get; set; }
public string Encoding { get; set; }
public string Schema { get; set; }

public string Identifier { get; set; }
public object Data { get; set; }
public ResourceReference Reference { get; set; }
Expand All @@ -34,7 +41,17 @@ public void WriteXml(XmlWriter writer)
if (Data != null)
{
writer.WriteStartElement("wps", "Data", ModelNamespaces.Wps);
writer.WriteRaw(xmlSerializer.Serialize(Data, true));
if (!string.IsNullOrEmpty(MimeType)) writer.WriteAttributeString("mimeType", MimeType);
if (!string.IsNullOrEmpty(Encoding)) writer.WriteAttributeString("encoding", Encoding);
if (!string.IsNullOrEmpty(Schema)) writer.WriteAttributeString("schema", Schema);
if (Data is string s)
{
writer.WriteRaw(s);
}
else
{
writer.WriteRaw(xmlSerializer.Serialize(Data, true));
}
writer.WriteEndElement();
}

Expand Down
12 changes: 10 additions & 2 deletions src/Wps/Wps.Client/Models/ResultOutput.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Xml;
using System;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using Wps.Client.Services;
Expand Down Expand Up @@ -47,7 +48,14 @@ public void ReadXml(XmlReader reader)
if (subtreeReader.LocalName.Equals("Data"))
{
var content = subtreeReader.ReadInnerXml();
Data = serializer.Deserialize<TData>(content);
if (typeof(TData) == typeof(string))
{
Data = (TData) Convert.ChangeType(content, typeof(string));
}
else
{
Data = serializer.Deserialize<TData>(content);
}
}

if (subtreeReader.LocalName.Equals("Output"))
Expand Down
27 changes: 26 additions & 1 deletion src/Wps/Wps.Client/Wps.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Authors>Mihai Stan, Benjamin Pross</Authors>
<Company>52°North</Company>
<Product>WPS Library</Product>
<Description>This is a library that allows developers to speed up their development when working with WPS providers.</Description>
<RepositoryUrl>https://github.com/52North/wps.net</RepositoryUrl>
<PackageTags>wps library client</PackageTags>
<PackageProjectUrl>https://github.com/52North/wps.net</PackageProjectUrl>
<PackageLicenseExpression></PackageLicenseExpression>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageId>Wps.Net</PackageId>
<Version>1.0.3</Version>
</PropertyGroup>

<ItemGroup>
<Folder Include="Extensions\" />
<Folder Include="Exceptions\" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\..\LICENSE">
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>

</Project>

0 comments on commit 7099d7e

Please sign in to comment.