This repository has been archived by the owner on Oct 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jenkinsworldpay
committed
Jan 24, 2017
1 parent
4fe863e
commit fbd1b19
Showing
465 changed files
with
88,454 additions
and
39,971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
TestResults | ||
obj | ||
*.suo | ||
TestResults | ||
obj | ||
*.suo | ||
*.user |
142 changes: 71 additions & 71 deletions
142
worldpay-lib-dotnet-2-0/Newtonsoft.Json/Converters/HtmlColorConverter.cs
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,71 @@ | ||
#region License | ||
// Copyright (c) 2007 James Newton-King | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
#endregion | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Drawing; | ||
|
||
namespace Newtonsoft.Json.Converters | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="Color"/> object to and from JSON. | ||
/// </summary> | ||
public class HtmlColorConverter : JsonConverter | ||
{ | ||
/// <summary> | ||
/// Writes the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> | ||
/// <param name="value">The value.</param> | ||
public override void WriteJson(JsonWriter writer, object value) | ||
{ | ||
writer.WriteValue(ColorTranslator.ToHtml((Color)value)); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether this instance can convert the specified value type. | ||
/// </summary> | ||
/// <param name="valueType">Type of the value.</param> | ||
/// <returns> | ||
/// <c>true</c> if this instance can convert the specified value type; otherwise, <c>false</c>. | ||
/// </returns> | ||
public override bool CanConvert(Type valueType) | ||
{ | ||
return typeof(Color).IsAssignableFrom(valueType); | ||
} | ||
|
||
/// <summary> | ||
/// Reads the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns>The object value.</returns> | ||
public override object ReadJson(JsonReader reader, Type objectType) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} | ||
#region License | ||
// Copyright (c) 2007 James Newton-King | ||
// | ||
// Permission is hereby granted, free of charge, to any person | ||
// obtaining a copy of this software and associated documentation | ||
// files (the "Software"), to deal in the Software without | ||
// restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the | ||
// Software is furnished to do so, subject to the following | ||
// conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
// OTHER DEALINGS IN THE SOFTWARE. | ||
#endregion | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Drawing; | ||
|
||
namespace Newtonsoft.Json.Converters | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="Color"/> object to and from JSON. | ||
/// </summary> | ||
public class HtmlColorConverter : JsonConverter | ||
{ | ||
/// <summary> | ||
/// Writes the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> | ||
/// <param name="value">The value.</param> | ||
public override void WriteJson(JsonWriter writer, object value) | ||
{ | ||
writer.WriteValue(ColorTranslator.ToHtml((Color)value)); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether this instance can convert the specified value type. | ||
/// </summary> | ||
/// <param name="valueType">Type of the value.</param> | ||
/// <returns> | ||
/// <c>true</c> if this instance can convert the specified value type; otherwise, <c>false</c>. | ||
/// </returns> | ||
public override bool CanConvert(Type valueType) | ||
{ | ||
return typeof(Color).IsAssignableFrom(valueType); | ||
} | ||
|
||
/// <summary> | ||
/// Reads the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns>The object value.</returns> | ||
public override object ReadJson(JsonReader reader, Type objectType) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
178 changes: 89 additions & 89 deletions
178
worldpay-lib-dotnet-2-0/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,90 @@ | ||
using System; | ||
using System.Globalization; | ||
using Newtonsoft.Json.Utilities; | ||
|
||
namespace Newtonsoft.Json.Converters | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="DateTime"/> to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z). | ||
/// </summary> | ||
public class IsoDateTimeConverter : JsonConverter | ||
{ | ||
private const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"; | ||
|
||
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind; | ||
|
||
/// <summary> | ||
/// Gets or sets the date time styles used when converting a date to and from JSON. | ||
/// </summary> | ||
/// <value>The date time styles used when converting a date to and from JSON.</value> | ||
public DateTimeStyles DateTimeStyles | ||
{ | ||
get { return _dateTimeStyles; } | ||
set { _dateTimeStyles = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Writes the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> | ||
/// <param name="value">The value.</param> | ||
public override void WriteJson(JsonWriter writer, object value) | ||
{ | ||
string text; | ||
|
||
if (value is DateTime) | ||
{ | ||
DateTime dateTime = (DateTime)value; | ||
|
||
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal | ||
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal) | ||
dateTime = dateTime.ToUniversalTime(); | ||
|
||
text = dateTime.ToString(DateTimeFormat, CultureInfo.InvariantCulture); | ||
} | ||
else | ||
{ | ||
DateTimeOffset dateTimeOffset = (DateTimeOffset)value; | ||
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal | ||
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal) | ||
dateTimeOffset = dateTimeOffset.ToUniversalTime(); | ||
|
||
text = dateTimeOffset.ToString(DateTimeFormat, CultureInfo.InvariantCulture); | ||
} | ||
|
||
writer.WriteValue(text); | ||
} | ||
|
||
/// <summary> | ||
/// Reads the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns>The object value.</returns> | ||
public override object ReadJson(JsonReader reader, Type objectType) | ||
{ | ||
if (reader.TokenType != JsonToken.String) | ||
throw new Exception("Unexpected token parsing date. Expected String, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType)); | ||
|
||
string dateText = reader.Value.ToString(); | ||
|
||
if (objectType == typeof(DateTimeOffset)) | ||
return DateTimeOffset.Parse(dateText, CultureInfo.InvariantCulture, _dateTimeStyles); | ||
|
||
return DateTime.Parse(dateText, CultureInfo.InvariantCulture, _dateTimeStyles); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether this instance can convert the specified object type. | ||
/// </summary> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns> | ||
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>. | ||
/// </returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return (typeof(DateTime).IsAssignableFrom(objectType) | ||
|| typeof(DateTimeOffset).IsAssignableFrom(objectType)); | ||
} | ||
} | ||
using System; | ||
using System.Globalization; | ||
using Newtonsoft.Json.Utilities; | ||
|
||
namespace Newtonsoft.Json.Converters | ||
{ | ||
/// <summary> | ||
/// Converts a <see cref="DateTime"/> to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z). | ||
/// </summary> | ||
public class IsoDateTimeConverter : JsonConverter | ||
{ | ||
private const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"; | ||
|
||
private DateTimeStyles _dateTimeStyles = DateTimeStyles.RoundtripKind; | ||
|
||
/// <summary> | ||
/// Gets or sets the date time styles used when converting a date to and from JSON. | ||
/// </summary> | ||
/// <value>The date time styles used when converting a date to and from JSON.</value> | ||
public DateTimeStyles DateTimeStyles | ||
{ | ||
get { return _dateTimeStyles; } | ||
set { _dateTimeStyles = value; } | ||
} | ||
|
||
/// <summary> | ||
/// Writes the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="writer">The <see cref="JsonWriter"/> to write to.</param> | ||
/// <param name="value">The value.</param> | ||
public override void WriteJson(JsonWriter writer, object value) | ||
{ | ||
string text; | ||
|
||
if (value is DateTime) | ||
{ | ||
DateTime dateTime = (DateTime)value; | ||
|
||
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal | ||
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal) | ||
dateTime = dateTime.ToUniversalTime(); | ||
|
||
text = dateTime.ToString(DateTimeFormat, CultureInfo.InvariantCulture); | ||
} | ||
else | ||
{ | ||
DateTimeOffset dateTimeOffset = (DateTimeOffset)value; | ||
if ((_dateTimeStyles & DateTimeStyles.AdjustToUniversal) == DateTimeStyles.AdjustToUniversal | ||
|| (_dateTimeStyles & DateTimeStyles.AssumeUniversal) == DateTimeStyles.AssumeUniversal) | ||
dateTimeOffset = dateTimeOffset.ToUniversalTime(); | ||
|
||
text = dateTimeOffset.ToString(DateTimeFormat, CultureInfo.InvariantCulture); | ||
} | ||
|
||
writer.WriteValue(text); | ||
} | ||
|
||
/// <summary> | ||
/// Reads the JSON representation of the object. | ||
/// </summary> | ||
/// <param name="reader">The <see cref="JsonReader"/> to read from.</param> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns>The object value.</returns> | ||
public override object ReadJson(JsonReader reader, Type objectType) | ||
{ | ||
if (reader.TokenType != JsonToken.String) | ||
throw new Exception("Unexpected token parsing date. Expected String, got {0}.".FormatWith(CultureInfo.InvariantCulture, reader.TokenType)); | ||
|
||
string dateText = reader.Value.ToString(); | ||
|
||
if (objectType == typeof(DateTimeOffset)) | ||
return DateTimeOffset.Parse(dateText, CultureInfo.InvariantCulture, _dateTimeStyles); | ||
|
||
return DateTime.Parse(dateText, CultureInfo.InvariantCulture, _dateTimeStyles); | ||
} | ||
|
||
/// <summary> | ||
/// Determines whether this instance can convert the specified object type. | ||
/// </summary> | ||
/// <param name="objectType">Type of the object.</param> | ||
/// <returns> | ||
/// <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>. | ||
/// </returns> | ||
public override bool CanConvert(Type objectType) | ||
{ | ||
return (typeof(DateTime).IsAssignableFrom(objectType) | ||
|| typeof(DateTimeOffset).IsAssignableFrom(objectType)); | ||
} | ||
} | ||
} |
Oops, something went wrong.