-Fixed potential race condition serializing F# objects
-Fixed schema divisible sometimes incorrectly validating to false -Fixed not calling virtual ShouldSerialize methods
This commit is contained in:
@@ -29,6 +29,7 @@ using System.Globalization;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if !(NET20 || NET35 || PORTABLE)
|
||||
using System.Numerics;
|
||||
#endif
|
||||
|
||||
@@ -115,6 +115,22 @@ namespace Newtonsoft.Json.Tests.Converters
|
||||
}
|
||||
|
||||
#if !NET20
|
||||
[Test]
|
||||
public void GroupElementsOfTheSameName()
|
||||
{
|
||||
string xml = "<root><p>Text1<span>Span1</span> <span>Span2</span> Text2</p></root>";
|
||||
|
||||
string json = JsonConvert.SerializeXNode(XElement.Parse(xml));
|
||||
|
||||
Assert.AreEqual(@"{""root"":{""p"":{""#text"":[""Text1"","" Text2""],""span"":[""Span1"",""Span2""]}}}", json);
|
||||
|
||||
XDocument doc = JsonConvert.DeserializeXNode(json);
|
||||
|
||||
Assert.AreEqual(@"<root>
|
||||
<p>Text1 Text2<span>Span1</span><span>Span2</span></p>
|
||||
</root>", doc.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializeEmptyDocument()
|
||||
{
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
{
|
||||
#region Usage
|
||||
JsonSchema schema = JsonSchema.Parse(@"{
|
||||
'description': 'A person',
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'name': {'type':'string'},
|
||||
@@ -29,7 +28,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
|
||||
'hobbies': ['.NET', 'Blogging', 'Reading', 'Xbox', 'LOLCATS']
|
||||
}");
|
||||
|
||||
bool valid = person.IsValid(schema);
|
||||
IList<string> errorMessages;
|
||||
bool valid = person.IsValid(schema, out errorMessages);
|
||||
|
||||
Console.WriteLine(valid);
|
||||
// true
|
||||
|
||||
@@ -952,7 +952,7 @@ now brown cow?", '"', true);
|
||||
#pragma warning disable 612,618
|
||||
Task taskVoid = JsonConvert.PopulateObjectAsync("{'Name':'Appended'}", p, new JsonSerializerSettings
|
||||
{
|
||||
Converters = new List<JsonConverter> { new JsonSerializerTest.StringAppenderConverter() }
|
||||
Converters = new List<JsonConverter> { new StringAppenderConverter() }
|
||||
});
|
||||
#pragma warning restore 612,618
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
#if !(NET20 || NET35 || PORTABLE)
|
||||
using System.Numerics;
|
||||
#endif
|
||||
|
||||
@@ -98,15 +98,24 @@
|
||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\DynamicTests.cs" />
|
||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
<Compile Include="TestObjects\AnswerFilterModel.cs" />
|
||||
<Compile Include="TestObjects\Antworten.cs" />
|
||||
<Compile Include="TestObjects\Bar.cs" />
|
||||
<Compile Include="TestObjects\Bb.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\Component.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
@@ -116,38 +125,59 @@
|
||||
<Compile Include="TestObjects\CustomerDataSet.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeWrapper.cs" />
|
||||
<Compile Include="TestObjects\DecimalTestClass.cs" />
|
||||
<Compile Include="TestObjects\DictionaryInterfaceClass.cs" />
|
||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||
<Compile Include="TestObjects\DirectoryAccount.cs" />
|
||||
<Compile Include="TestObjects\Event.cs" />
|
||||
<Compile Include="TestObjects\Event1.cs" />
|
||||
<Compile Include="TestObjects\Foo.cs" />
|
||||
<Compile Include="TestObjects\GameObject.cs" />
|
||||
<Compile Include="TestObjects\GoogleMapGeocoderStructure.cs" />
|
||||
<Compile Include="TestObjects\HolderClass.cs" />
|
||||
<Compile Include="TestObjects\IdReferenceResolver.cs" />
|
||||
<Compile Include="TestObjects\IMyInterface.cs" />
|
||||
<Compile Include="TestObjects\InterfacePropertyTestClass.cs" />
|
||||
<Compile Include="TestObjects\IntToFloatConverter.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
|
||||
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
|
||||
<Compile Include="TestObjects\Item.cs" />
|
||||
<Compile Include="TestObjects\JsonPropertyClass.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerTest.cs" />
|
||||
<Compile Include="TestObjects\ListOfIds.cs" />
|
||||
<Compile Include="TestObjects\ListTestClass.cs" />
|
||||
<Compile Include="TestObjects\LogEntry.cs" />
|
||||
<Compile Include="Serialization\MissingMemberHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
|
||||
<Compile Include="TestObjects\MetroStringConverter.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\NonRequest.cs" />
|
||||
<Compile Include="TestObjects\NullableGuid.cs" />
|
||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||
<Compile Include="Serialization\PopulateTests.cs" />
|
||||
<Compile Include="TestObjects\ParticipantEntity.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\PersonReference.cs" />
|
||||
<Compile Include="TestObjects\PersonSerializable.cs" />
|
||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
||||
<Compile Include="TestObjects\Ratio.cs" />
|
||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||
<Compile Include="TestObjects\RoleTransfer.cs" />
|
||||
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
|
||||
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
|
||||
@@ -157,6 +187,7 @@
|
||||
<Compile Include="Serialization\CamelCasePropertyNamesContractResolverTests.cs" />
|
||||
<Compile Include="Serialization\PreserveReferencesHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\SearchResult.cs" />
|
||||
<Compile Include="TestObjects\SelectListItem.cs" />
|
||||
<Compile Include="TestObjects\SetOnlyPropertyClass2.cs" />
|
||||
<Compile Include="TestObjects\StructTest.cs" />
|
||||
<Compile Include="TestObjects\SubKlass.cs" />
|
||||
@@ -237,11 +268,21 @@
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestFixtureBase.cs" />
|
||||
<Compile Include="Converters\XmlNodeConverterTest.cs" />
|
||||
<Compile Include="TestObjects\TestComponent.cs" />
|
||||
<Compile Include="TestObjects\TestComponentSimple.cs" />
|
||||
<Compile Include="TestObjects\TestObject.cs" />
|
||||
<Compile Include="TestObjects\TypeClass.cs" />
|
||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
|
||||
<Compile Include="TestObjects\UserNullable.cs" />
|
||||
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
||||
<Compile Include="TestObjects\WagePerson.cs" />
|
||||
<Compile Include="TestObjects\Widget.cs" />
|
||||
<Compile Include="TestObjects\Widget1.cs" />
|
||||
<Compile Include="TestObjects\WidgetId.cs" />
|
||||
<Compile Include="TestObjects\WidgetId1.cs" />
|
||||
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
|
||||
<Compile Include="TestObjects\WithEnums.cs" />
|
||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||
|
||||
@@ -140,16 +140,24 @@
|
||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\DynamicTests.cs" />
|
||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
<Compile Include="TestObjects\AnswerFilterModel.cs" />
|
||||
<Compile Include="TestObjects\Antworten.cs" />
|
||||
<Compile Include="TestObjects\Bar.cs" />
|
||||
<Compile Include="TestObjects\Bb.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\Component.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
@@ -158,15 +166,34 @@
|
||||
<Compile Include="TestObjects\CustomerDataSet.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeWrapper.cs" />
|
||||
<Compile Include="TestObjects\DecimalTestClass.cs" />
|
||||
<Compile Include="TestObjects\DirectoryAccount.cs" />
|
||||
<Compile Include="TestObjects\Event1.cs" />
|
||||
<Compile Include="TestObjects\Foo.cs" />
|
||||
<Compile Include="TestObjects\GameObject.cs" />
|
||||
<Compile Include="TestObjects\HolderClass.cs" />
|
||||
<Compile Include="TestObjects\IdReferenceResolver.cs" />
|
||||
<Compile Include="TestObjects\IMyInterface.cs" />
|
||||
<Compile Include="TestObjects\IntToFloatConverter.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
|
||||
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
|
||||
<Compile Include="TestObjects\Item.cs" />
|
||||
<Compile Include="TestObjects\ListOfIds.cs" />
|
||||
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
|
||||
<Compile Include="TestObjects\MetroStringConverter.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\NullableGuid.cs" />
|
||||
<Compile Include="TestObjects\ParticipantEntity.cs" />
|
||||
<Compile Include="TestObjects\PersonReference.cs" />
|
||||
<Compile Include="TestObjects\PersonSerializable.cs" />
|
||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
@@ -199,8 +226,15 @@
|
||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
||||
<Compile Include="TestObjects\Ratio.cs" />
|
||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||
<Compile Include="TestObjects\SearchResult.cs" />
|
||||
<Compile Include="TestObjects\SelectListItem.cs" />
|
||||
<Compile Include="TestObjects\StructTest.cs" />
|
||||
<Compile Include="TestObjects\TestComponent.cs" />
|
||||
<Compile Include="TestObjects\TestComponentSimple.cs" />
|
||||
<Compile Include="TestObjects\TestObject.cs" />
|
||||
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
|
||||
<Compile Include="TestObjects\WagePerson.cs" />
|
||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||
@@ -285,6 +319,12 @@
|
||||
<Compile Include="TestObjects\TypeClass.cs" />
|
||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||
<Compile Include="TestObjects\UserNullable.cs" />
|
||||
<Compile Include="TestObjects\Widget.cs" />
|
||||
<Compile Include="TestObjects\Widget1.cs" />
|
||||
<Compile Include="TestObjects\WidgetId.cs" />
|
||||
<Compile Include="TestObjects\WidgetId1.cs" />
|
||||
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
|
||||
<Compile Include="TestObjects\WithEnums.cs" />
|
||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||
|
||||
@@ -262,16 +262,24 @@
|
||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\DynamicTests.cs" />
|
||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
<Compile Include="TestObjects\AnswerFilterModel.cs" />
|
||||
<Compile Include="TestObjects\Antworten.cs" />
|
||||
<Compile Include="TestObjects\Bar.cs" />
|
||||
<Compile Include="TestObjects\Bb.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\Component.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
@@ -280,15 +288,33 @@
|
||||
<Compile Include="TestObjects\CustomerDataSet.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeWrapper.cs" />
|
||||
<Compile Include="TestObjects\DecimalTestClass.cs" />
|
||||
<Compile Include="TestObjects\DirectoryAccount.cs" />
|
||||
<Compile Include="TestObjects\Event1.cs" />
|
||||
<Compile Include="TestObjects\Foo.cs" />
|
||||
<Compile Include="TestObjects\GameObject.cs" />
|
||||
<Compile Include="TestObjects\HolderClass.cs" />
|
||||
<Compile Include="TestObjects\IdReferenceResolver.cs" />
|
||||
<Compile Include="TestObjects\IMyInterface.cs" />
|
||||
<Compile Include="TestObjects\IntToFloatConverter.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
|
||||
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
|
||||
<Compile Include="TestObjects\Item.cs" />
|
||||
<Compile Include="TestObjects\ListOfIds.cs" />
|
||||
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
|
||||
<Compile Include="TestObjects\MetroStringConverter.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\NullableGuid.cs" />
|
||||
<Compile Include="TestObjects\ParticipantEntity.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\PersonReference.cs" />
|
||||
<Compile Include="TestObjects\PersonSerializable.cs" />
|
||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\Content.cs" />
|
||||
@@ -317,12 +343,20 @@
|
||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
||||
<Compile Include="TestObjects\Ratio.cs" />
|
||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||
<Compile Include="TestObjects\SearchResult.cs" />
|
||||
<Compile Include="TestObjects\SelectListItem.cs" />
|
||||
<Compile Include="TestObjects\StructTest.cs" />
|
||||
<Compile Include="TestObjects\TestComponent.cs" />
|
||||
<Compile Include="TestObjects\TestComponentSimple.cs" />
|
||||
<Compile Include="TestObjects\TestObject.cs" />
|
||||
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
|
||||
<Compile Include="TestObjects\WagePerson.cs" />
|
||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||
@@ -407,6 +441,12 @@
|
||||
<Compile Include="TestObjects\TypeClass.cs" />
|
||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||
<Compile Include="TestObjects\UserNullable.cs" />
|
||||
<Compile Include="TestObjects\Widget.cs" />
|
||||
<Compile Include="TestObjects\Widget1.cs" />
|
||||
<Compile Include="TestObjects\WidgetId.cs" />
|
||||
<Compile Include="TestObjects\WidgetId1.cs" />
|
||||
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
|
||||
<Compile Include="TestObjects\WithEnums.cs" />
|
||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||
|
||||
@@ -146,31 +146,57 @@
|
||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\DynamicTests.cs" />
|
||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
<Compile Include="TestObjects\AnswerFilterModel.cs" />
|
||||
<Compile Include="TestObjects\Antworten.cs" />
|
||||
<Compile Include="TestObjects\Bar.cs" />
|
||||
<Compile Include="TestObjects\Bb.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\Component.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
<Compile Include="TestObjects\ContentBaseClass.cs" />
|
||||
<Compile Include="TestObjects\ContentSubClass.cs" />
|
||||
<Compile Include="TestObjects\CustomerDataSet.cs" />
|
||||
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeWrapper.cs" />
|
||||
<Compile Include="TestObjects\DecimalTestClass.cs" />
|
||||
<Compile Include="TestObjects\DirectoryAccount.cs" />
|
||||
<Compile Include="TestObjects\Event1.cs" />
|
||||
<Compile Include="TestObjects\Foo.cs" />
|
||||
<Compile Include="TestObjects\GameObject.cs" />
|
||||
<Compile Include="TestObjects\HolderClass.cs" />
|
||||
<Compile Include="TestObjects\IdReferenceResolver.cs" />
|
||||
<Compile Include="TestObjects\IMyInterface.cs" />
|
||||
<Compile Include="TestObjects\IntToFloatConverter.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
|
||||
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
|
||||
<Compile Include="TestObjects\Item.cs" />
|
||||
<Compile Include="TestObjects\ListOfIds.cs" />
|
||||
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
|
||||
<Compile Include="TestObjects\MetroStringConverter.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\NullableGuid.cs" />
|
||||
<Compile Include="TestObjects\ParticipantEntity.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\PersonReference.cs" />
|
||||
<Compile Include="TestObjects\PersonSerializable.cs" />
|
||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\Content.cs" />
|
||||
@@ -199,12 +225,20 @@
|
||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
||||
<Compile Include="TestObjects\Ratio.cs" />
|
||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||
<Compile Include="TestObjects\SearchResult.cs" />
|
||||
<Compile Include="TestObjects\SelectListItem.cs" />
|
||||
<Compile Include="TestObjects\StructTest.cs" />
|
||||
<Compile Include="TestObjects\TestComponent.cs" />
|
||||
<Compile Include="TestObjects\TestComponentSimple.cs" />
|
||||
<Compile Include="TestObjects\TestObject.cs" />
|
||||
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
|
||||
<Compile Include="TestObjects\WagePerson.cs" />
|
||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||
@@ -289,6 +323,12 @@
|
||||
<Compile Include="TestObjects\TypeClass.cs" />
|
||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||
<Compile Include="TestObjects\UserNullable.cs" />
|
||||
<Compile Include="TestObjects\Widget.cs" />
|
||||
<Compile Include="TestObjects\Widget1.cs" />
|
||||
<Compile Include="TestObjects\WidgetId.cs" />
|
||||
<Compile Include="TestObjects\WidgetId1.cs" />
|
||||
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
|
||||
<Compile Include="TestObjects\WithEnums.cs" />
|
||||
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||
|
||||
@@ -142,29 +142,57 @@
|
||||
<Compile Include="Serialization\ContractResolverTests.cs" />
|
||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\DynamicTests.cs" />
|
||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
<Compile Include="Serialization\NullValueHandlingTests.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
<Compile Include="TestObjects\AnswerFilterModel.cs" />
|
||||
<Compile Include="TestObjects\Antworten.cs" />
|
||||
<Compile Include="TestObjects\Bar.cs" />
|
||||
<Compile Include="TestObjects\Bb.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\Component.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
|
||||
<Compile Include="TestObjects\Container.cs" />
|
||||
<Compile Include="TestObjects\ContentBaseClass.cs" />
|
||||
<Compile Include="TestObjects\ContentSubClass.cs" />
|
||||
<Compile Include="TestObjects\CustomerDataSet.cs" />
|
||||
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeWrapper.cs" />
|
||||
<Compile Include="TestObjects\DecimalTestClass.cs" />
|
||||
<Compile Include="TestObjects\DirectoryAccount.cs" />
|
||||
<Compile Include="TestObjects\Event1.cs" />
|
||||
<Compile Include="TestObjects\Foo.cs" />
|
||||
<Compile Include="TestObjects\GameObject.cs" />
|
||||
<Compile Include="TestObjects\HolderClass.cs" />
|
||||
<Compile Include="TestObjects\IdReferenceResolver.cs" />
|
||||
<Compile Include="TestObjects\IMyInterface.cs" />
|
||||
<Compile Include="TestObjects\IntToFloatConverter.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
|
||||
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
|
||||
<Compile Include="TestObjects\Item.cs" />
|
||||
<Compile Include="TestObjects\ListOfIds.cs" />
|
||||
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
|
||||
<Compile Include="TestObjects\MetroStringConverter.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\NullableGuid.cs" />
|
||||
<Compile Include="TestObjects\ParticipantEntity.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\PersonReference.cs" />
|
||||
<Compile Include="TestObjects\PersonSerializable.cs" />
|
||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\Content.cs" />
|
||||
@@ -193,12 +221,20 @@
|
||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationBClass.cs" />
|
||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
||||
<Compile Include="TestObjects\Ratio.cs" />
|
||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||
<Compile Include="TestObjects\SearchResult.cs" />
|
||||
<Compile Include="TestObjects\SelectListItem.cs" />
|
||||
<Compile Include="TestObjects\StructTest.cs" />
|
||||
<Compile Include="TestObjects\TestComponent.cs" />
|
||||
<Compile Include="TestObjects\TestComponentSimple.cs" />
|
||||
<Compile Include="TestObjects\TestObject.cs" />
|
||||
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
|
||||
<Compile Include="TestObjects\WagePerson.cs" />
|
||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||
@@ -283,6 +319,12 @@
|
||||
<Compile Include="TestObjects\TypeClass.cs" />
|
||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||
<Compile Include="TestObjects\UserNullable.cs" />
|
||||
<Compile Include="TestObjects\Widget.cs" />
|
||||
<Compile Include="TestObjects\Widget1.cs" />
|
||||
<Compile Include="TestObjects\WidgetId.cs" />
|
||||
<Compile Include="TestObjects\WidgetId1.cs" />
|
||||
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
|
||||
<Compile Include="TestObjects\WithEnums.cs" />
|
||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||
|
||||
@@ -237,6 +237,7 @@
|
||||
<Compile Include="Serialization\DefaultValueHandlingTests.cs" />
|
||||
<Compile Include="Serialization\DynamicTests.cs" />
|
||||
<Compile Include="Serialization\EntitiesSerializationTests.cs" />
|
||||
<Compile Include="Serialization\ExtensionDataTests.cs" />
|
||||
<Compile Include="Serialization\FSharpTests.cs" />
|
||||
<Compile Include="Serialization\ImmutableCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\JsonPropertyCollectionTests.cs" />
|
||||
@@ -248,17 +249,23 @@
|
||||
<Compile Include="Serialization\ReferenceLoopHandlingTests.cs" />
|
||||
<Compile Include="Serialization\SerializationErrorHandlingTests.cs" />
|
||||
<Compile Include="Serialization\SerializationEventAttributeTests.cs" />
|
||||
<Compile Include="Serialization\JsonSerializerCollectionsTests.cs" />
|
||||
<Compile Include="Serialization\ShouldSerializeTests.cs" />
|
||||
<Compile Include="Serialization\SpecialPropertyHandlingTests.cs" />
|
||||
<Compile Include="Serialization\TraceWriterTests.cs" />
|
||||
<Compile Include="Serialization\TypeNameHandlingTests.cs" />
|
||||
<Compile Include="Serialization\WebApiIntegrationTests.cs" />
|
||||
<Compile Include="TestFixtureBase.cs" />
|
||||
<Compile Include="TestObjects\Aa.cs" />
|
||||
<Compile Include="TestObjects\AbstractGenericBase.cs" />
|
||||
<Compile Include="TestObjects\AnswerFilterModel.cs" />
|
||||
<Compile Include="TestObjects\Antworten.cs" />
|
||||
<Compile Include="TestObjects\ArgumentConverterPrecedenceClassConverter.cs" />
|
||||
<Compile Include="TestObjects\Article.cs" />
|
||||
<Compile Include="TestObjects\ArticleCollection.cs" />
|
||||
<Compile Include="TestObjects\BadJsonPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\Bar.cs" />
|
||||
<Compile Include="TestObjects\Bb.cs" />
|
||||
<Compile Include="TestObjects\Car.cs" />
|
||||
<Compile Include="TestObjects\CircularReferenceClass.cs" />
|
||||
<Compile Include="TestObjects\CircularReferenceWithIdClass.cs" />
|
||||
@@ -266,6 +273,7 @@
|
||||
<Compile Include="TestObjects\ClassConverterPrecedenceClassConverter.cs" />
|
||||
<Compile Include="TestObjects\ClassWithArray.cs" />
|
||||
<Compile Include="TestObjects\ClassWithGuid.cs" />
|
||||
<Compile Include="TestObjects\Component.cs" />
|
||||
<Compile Include="TestObjects\Computer.cs" />
|
||||
<Compile Include="TestObjects\ConstructorCaseSensitivityClass.cs" />
|
||||
<Compile Include="TestObjects\ConstructorReadonlyFields.cs" />
|
||||
@@ -279,25 +287,35 @@
|
||||
<Compile Include="TestObjects\CustomerDataSet.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="TestObjects\DataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeErrorObjectCollection.cs" />
|
||||
<Compile Include="TestObjects\DateTimeTestClass.cs" />
|
||||
<Compile Include="TestObjects\DateTimeWrapper.cs" />
|
||||
<Compile Include="TestObjects\DecimalTestClass.cs" />
|
||||
<Compile Include="TestObjects\DefaultValueAttributeTestClass.cs" />
|
||||
<Compile Include="TestObjects\DictionaryInterfaceClass.cs" />
|
||||
<Compile Include="TestObjects\DirectoryAccount.cs" />
|
||||
<Compile Include="TestObjects\DoubleClass.cs" />
|
||||
<Compile Include="TestObjects\EmployeeReference.cs" />
|
||||
<Compile Include="TestObjects\Event.cs" />
|
||||
<Compile Include="TestObjects\Event1.cs" />
|
||||
<Compile Include="TestObjects\Foo.cs" />
|
||||
<Compile Include="TestObjects\GameObject.cs" />
|
||||
<Compile Include="TestObjects\GenericImpl.cs" />
|
||||
<Compile Include="TestObjects\GenericListAndDictionaryInterfaceProperties.cs" />
|
||||
<Compile Include="TestObjects\GetOnlyPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\GoogleMapGeocoderStructure.cs" />
|
||||
<Compile Include="TestObjects\HolderClass.cs" />
|
||||
<Compile Include="TestObjects\IdReferenceResolver.cs" />
|
||||
<Compile Include="TestObjects\IMyInterface.cs" />
|
||||
<Compile Include="TestObjects\IncompatibleJsonAttributeClass.cs" />
|
||||
<Compile Include="TestObjects\InterfacePropertyTestClass.cs" />
|
||||
<Compile Include="TestObjects\IntToFloatConverter.cs" />
|
||||
<Compile Include="TestObjects\Invoice.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationA.cs" />
|
||||
<Compile Include="TestObjects\IPrivateImplementationB.cs" />
|
||||
<Compile Include="TestObjects\IPrivateOverriddenImplementation.cs" />
|
||||
<Compile Include="TestObjects\Item.cs" />
|
||||
<Compile Include="TestObjects\JaggedArray.cs" />
|
||||
<Compile Include="TestObjects\JsonIgnoreAttributeOnClassTestClass.cs" />
|
||||
<Compile Include="TestObjects\JsonIgnoreAttributeTestClass.cs" />
|
||||
@@ -311,17 +329,25 @@
|
||||
<Compile Include="TestObjects\MemberConverterClass.cs" />
|
||||
<Compile Include="TestObjects\MemberConverterPrecedenceClassConverter.cs" />
|
||||
<Compile Include="TestObjects\MethodExecutorObject.cs" />
|
||||
<Compile Include="TestObjects\MetroPropertyNameResolver.cs" />
|
||||
<Compile Include="TestObjects\MetroStringConverter.cs" />
|
||||
<Compile Include="TestObjects\Movie.cs" />
|
||||
<Compile Include="TestObjects\MyClass.cs" />
|
||||
<Compile Include="TestObjects\Name.cs" />
|
||||
<Compile Include="TestObjects\NonRequest.cs" />
|
||||
<Compile Include="TestObjects\NullableDateTimeTestClass.cs" />
|
||||
<Compile Include="TestObjects\NullableGuid.cs" />
|
||||
<Compile Include="TestObjects\ObjectArrayPropertyTest.cs" />
|
||||
<Compile Include="TestObjects\ParticipantEntity.cs" />
|
||||
<Compile Include="TestObjects\Person.cs" />
|
||||
<Compile Include="TestObjects\PersonError.cs" />
|
||||
<Compile Include="TestObjects\PersonPropertyClass.cs" />
|
||||
<Compile Include="TestObjects\PersonRaw.cs" />
|
||||
<Compile Include="TestObjects\PersonReference.cs" />
|
||||
<Compile Include="TestObjects\PersonSerializable.cs" />
|
||||
<Compile Include="TestObjects\PersonWithPrivateConstructor.cs" />
|
||||
<Compile Include="TestObjects\PhoneNumber.cs" />
|
||||
<Compile Include="TestObjects\PocoDataContractSerializationAttributesClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateConstructorWithPublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PrivateImplementationAClass.cs" />
|
||||
@@ -331,14 +357,18 @@
|
||||
<Compile Include="TestObjects\ProductCollection.cs" />
|
||||
<Compile Include="TestObjects\ProductShort.cs" />
|
||||
<Compile Include="TestObjects\PropertyCase.cs" />
|
||||
<Compile Include="TestObjects\PropertyItemConverter.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorRequiringConverterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithNonPropertyParameterTestClass.cs" />
|
||||
<Compile Include="TestObjects\PublicParametizedConstructorWithPropertyNameConflict.cs" />
|
||||
<Compile Include="TestObjects\Ratio.cs" />
|
||||
<Compile Include="TestObjects\RequestOnly.cs" />
|
||||
<Compile Include="TestObjects\RequiredMembersClass.cs" />
|
||||
<Compile Include="TestObjects\RequiredObject.cs" />
|
||||
<Compile Include="TestObjects\RoleTransfer.cs" />
|
||||
<Compile Include="TestObjects\SearchResult.cs" />
|
||||
<Compile Include="TestObjects\SelectListItem.cs" />
|
||||
<Compile Include="TestObjects\SerializationEventTestDictionary.cs" />
|
||||
<Compile Include="TestObjects\SerializationEventTestList.cs" />
|
||||
<Compile Include="TestObjects\SerializationEventTestObject.cs" />
|
||||
@@ -351,11 +381,21 @@
|
||||
<Compile Include="TestObjects\StructTest.cs" />
|
||||
<Compile Include="TestObjects\SubKlass.cs" />
|
||||
<Compile Include="TestObjects\SuperKlass.cs" />
|
||||
<Compile Include="TestObjects\TestComponent.cs" />
|
||||
<Compile Include="TestObjects\TestComponentSimple.cs" />
|
||||
<Compile Include="TestObjects\TestObject.cs" />
|
||||
<Compile Include="TestObjects\TypeClass.cs" />
|
||||
<Compile Include="TestObjects\TypedSubHashtable.cs" />
|
||||
<Compile Include="TestObjects\UriGuidTimeSpanTestClass.cs" />
|
||||
<Compile Include="TestObjects\UserNullable.cs" />
|
||||
<Compile Include="TestObjects\VersionKeyedCollection.cs" />
|
||||
<Compile Include="TestObjects\WagePerson.cs" />
|
||||
<Compile Include="TestObjects\Widget.cs" />
|
||||
<Compile Include="TestObjects\Widget1.cs" />
|
||||
<Compile Include="TestObjects\WidgetId.cs" />
|
||||
<Compile Include="TestObjects\WidgetId1.cs" />
|
||||
<Compile Include="TestObjects\WidgetIdJsonConverter.cs" />
|
||||
<Compile Include="TestObjects\WithEnums.cs" />
|
||||
<Compile Include="Utilities\DateTimeUtilsTests.cs" />
|
||||
<Compile Include="Utilities\DynamicReflectionDelegateFactoryTests.cs" />
|
||||
<Compile Include="Utilities\ExpressionReflectionDelegateFactoryTests.cs" />
|
||||
|
||||
@@ -75,4 +75,4 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("6.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("6.0.1.17117")]
|
||||
[assembly: AssemblyFileVersion("6.0.1.17131")]
|
||||
|
||||
@@ -308,6 +308,16 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DivisibleBy_Approx()
|
||||
{
|
||||
JsonSchema schema = new JsonSchema();
|
||||
schema.DivisibleBy = 0.01;
|
||||
|
||||
JValue v = new JValue(20.49);
|
||||
v.Validate(schema);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UniqueItems_SimpleUnique()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,599 @@
|
||||
#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 Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Tests.TestObjects;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
public class ExtensionDataTests : TestFixtureBase
|
||||
{
|
||||
public class ExtensionDataDeserializeWithNonDefaultConstructor
|
||||
{
|
||||
public ExtensionDataDeserializeWithNonDefaultConstructor(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> _extensionData;
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataDeserializeWithNonDefaultConstructorTest()
|
||||
{
|
||||
ExtensionDataDeserializeWithNonDefaultConstructor c = new ExtensionDataDeserializeWithNonDefaultConstructor("Name!");
|
||||
c._extensionData = new Dictionary<string, JToken>
|
||||
{
|
||||
{ "Key!", "Value!" }
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""Name"": ""Name!"",
|
||||
""Key!"": ""Value!""
|
||||
}", json);
|
||||
|
||||
var c2 = JsonConvert.DeserializeObject<ExtensionDataDeserializeWithNonDefaultConstructor>(json);
|
||||
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
Assert.IsNotNull(c2._extensionData);
|
||||
Assert.AreEqual(1, c2._extensionData.Count);
|
||||
Assert.AreEqual("Value!", (string)c2._extensionData["Key!"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataWithNull()
|
||||
{
|
||||
string json = @"{
|
||||
'TaxRate': 0.125,
|
||||
'a':null
|
||||
}";
|
||||
|
||||
var invoice = JsonConvert.DeserializeObject<ExtendedObject>(json);
|
||||
|
||||
Assert.AreEqual(JTokenType.Null, invoice._additionalData["a"].Type);
|
||||
Assert.AreEqual(typeof(double), ((JValue)invoice._additionalData["TaxRate"]).Value.GetType());
|
||||
|
||||
string result = JsonConvert.SerializeObject(invoice);
|
||||
|
||||
Assert.AreEqual(@"{""TaxRate"":0.125,""a"":null}", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataFloatParseHandling()
|
||||
{
|
||||
string json = @"{
|
||||
'TaxRate': 0.125,
|
||||
'a':null
|
||||
}";
|
||||
|
||||
var invoice = JsonConvert.DeserializeObject<ExtendedObject>(json, new JsonSerializerSettings
|
||||
{
|
||||
FloatParseHandling = FloatParseHandling.Decimal
|
||||
});
|
||||
|
||||
Assert.AreEqual(typeof(decimal), ((JValue)invoice._additionalData["TaxRate"]).Value.GetType());
|
||||
}
|
||||
|
||||
#pragma warning disable 649
|
||||
class ExtendedObject
|
||||
{
|
||||
[JsonExtensionData]
|
||||
internal IDictionary<string, JToken> _additionalData;
|
||||
}
|
||||
#pragma warning restore 649
|
||||
|
||||
#pragma warning disable 169
|
||||
public class CustomerInvoice
|
||||
{
|
||||
// we're only modifing the tax rate
|
||||
public decimal TaxRate { get; set; }
|
||||
|
||||
// everything else gets stored here
|
||||
[JsonExtensionData]
|
||||
private IDictionary<string, JToken> _additionalData;
|
||||
}
|
||||
#pragma warning restore 169
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataExample()
|
||||
{
|
||||
string json = @"{
|
||||
'HourlyRate': 150,
|
||||
'Hours': 40,
|
||||
'TaxRate': 0.125
|
||||
}";
|
||||
|
||||
var invoice = JsonConvert.DeserializeObject<CustomerInvoice>(json);
|
||||
|
||||
// increase tax to 15%
|
||||
invoice.TaxRate = 0.15m;
|
||||
|
||||
string result = JsonConvert.SerializeObject(invoice);
|
||||
// {
|
||||
// 'TaxRate': 0.15,
|
||||
// 'HourlyRate': 150,
|
||||
// 'Hours': 40
|
||||
// }
|
||||
|
||||
Assert.AreEqual(@"{""TaxRate"":0.15,""HourlyRate"":150,""Hours"":40}", result);
|
||||
}
|
||||
|
||||
public class ExtensionDataTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("custom_name")]
|
||||
public string CustomName { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public IList<int> Ignored { get; set; }
|
||||
|
||||
public bool GetPrivate { get; internal set; }
|
||||
|
||||
public bool GetOnly
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public readonly string Readonly = "Readonly";
|
||||
public IList<int> Ints { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
internal IDictionary<string, JToken> ExtensionData { get; set; }
|
||||
|
||||
public ExtensionDataTestClass()
|
||||
{
|
||||
Ints = new List<int> { 0 };
|
||||
}
|
||||
}
|
||||
|
||||
public class JObjectExtensionDataTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
public JObject ExtensionData { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RoundTripJObjectExtensionData()
|
||||
{
|
||||
JObjectExtensionDataTestClass c = new JObjectExtensionDataTestClass();
|
||||
c.Name = "Name!";
|
||||
c.ExtensionData = new JObject
|
||||
{
|
||||
{ "one", 1 },
|
||||
{ "two", "II" },
|
||||
{ "three", new JArray(1, 1, 1) }
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||
|
||||
JObjectExtensionDataTestClass c2 = JsonConvert.DeserializeObject<JObjectExtensionDataTestClass>(json);
|
||||
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
Assert.IsTrue(JToken.DeepEquals(c.ExtensionData, c2.ExtensionData));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataTest()
|
||||
{
|
||||
string json = @"{
|
||||
""Ints"": [1,2,3],
|
||||
""Ignored"": [1,2,3],
|
||||
""Readonly"": ""Readonly"",
|
||||
""Name"": ""Actually set!"",
|
||||
""CustomName"": ""Wrong name!"",
|
||||
""GetPrivate"": true,
|
||||
""GetOnly"": true,
|
||||
""NewValueSimple"": true,
|
||||
""NewValueComplex"": [1,2,3]
|
||||
}";
|
||||
|
||||
ExtensionDataTestClass c = JsonConvert.DeserializeObject<ExtensionDataTestClass>(json);
|
||||
|
||||
Assert.AreEqual("Actually set!", c.Name);
|
||||
Assert.AreEqual(4, c.Ints.Count);
|
||||
|
||||
Assert.AreEqual("Readonly", (string)c.ExtensionData["Readonly"]);
|
||||
Assert.AreEqual("Wrong name!", (string)c.ExtensionData["CustomName"]);
|
||||
Assert.AreEqual(true, (bool)c.ExtensionData["GetPrivate"]);
|
||||
Assert.AreEqual(true, (bool)c.ExtensionData["GetOnly"]);
|
||||
Assert.AreEqual(true, (bool)c.ExtensionData["NewValueSimple"]);
|
||||
Assert.IsTrue(JToken.DeepEquals(new JArray(1, 2, 3), c.ExtensionData["NewValueComplex"]));
|
||||
Assert.IsTrue(JToken.DeepEquals(new JArray(1, 2, 3), c.ExtensionData["Ignored"]));
|
||||
|
||||
Assert.AreEqual(7, c.ExtensionData.Count);
|
||||
}
|
||||
|
||||
public class MultipleExtensionDataAttributesTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
internal IDictionary<string, JToken> ExtensionData1 { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
internal IDictionary<string, JToken> ExtensionData2 { get; set; }
|
||||
}
|
||||
|
||||
public class ExtensionDataAttributesInheritanceTestClass : MultipleExtensionDataAttributesTestClass
|
||||
{
|
||||
[JsonExtensionData]
|
||||
internal IDictionary<string, JToken> ExtensionData0 { get; set; }
|
||||
}
|
||||
|
||||
public class FieldExtensionDataAttributeTestClass
|
||||
{
|
||||
[JsonExtensionData]
|
||||
internal IDictionary<object, object> ExtensionData;
|
||||
}
|
||||
|
||||
public class PublicExtensionDataAttributeTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
public IDictionary<object, object> ExtensionData;
|
||||
}
|
||||
|
||||
public class PublicExtensionDataAttributeTestClassWithNonDefaultConstructor
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public PublicExtensionDataAttributeTestClassWithNonDefaultConstructor(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
[JsonExtensionData]
|
||||
public IDictionary<object, object> ExtensionData;
|
||||
}
|
||||
|
||||
public class PublicNoReadExtensionDataAttributeTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonExtensionData(ReadData = false)]
|
||||
public IDictionary<object, object> ExtensionData;
|
||||
}
|
||||
|
||||
public class PublicNoWriteExtensionDataAttributeTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonExtensionData(WriteData = false)]
|
||||
public IDictionary<object, object> ExtensionData;
|
||||
}
|
||||
|
||||
public class PublicJTokenExtensionDataAttributeTestClass
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, JToken> ExtensionData;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializeDirectoryAccount()
|
||||
{
|
||||
string json = @"{'DisplayName':'John Smith', 'SAMAccountName':'contoso\\johns'}";
|
||||
|
||||
DirectoryAccount account = JsonConvert.DeserializeObject<DirectoryAccount>(json);
|
||||
|
||||
Assert.AreEqual("John Smith", account.DisplayName);
|
||||
Assert.AreEqual("contoso", account.Domain);
|
||||
Assert.AreEqual("johns", account.UserName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializePublicExtensionData()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(new PublicExtensionDataAttributeTestClass
|
||||
{
|
||||
Name = "Name!",
|
||||
ExtensionData = new Dictionary<object, object>
|
||||
{
|
||||
{ "Test", 1 }
|
||||
}
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{""Name"":""Name!"",""Test"":1}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializePublicExtensionDataNull()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(new PublicExtensionDataAttributeTestClass
|
||||
{
|
||||
Name = "Name!"
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{""Name"":""Name!""}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializePublicNoWriteExtensionData()
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(new PublicNoWriteExtensionDataAttributeTestClass
|
||||
{
|
||||
Name = "Name!",
|
||||
ExtensionData = new Dictionary<object, object>
|
||||
{
|
||||
{ "Test", 1 }
|
||||
}
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{""Name"":""Name!""}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializeNoReadPublicExtensionData()
|
||||
{
|
||||
PublicNoReadExtensionDataAttributeTestClass c = JsonConvert.DeserializeObject<PublicNoReadExtensionDataAttributeTestClass>(@"{""Name"":""Name!"",""Test"":1}");
|
||||
|
||||
Assert.AreEqual(null, c.ExtensionData);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializePublicExtensionDataCircularReference()
|
||||
{
|
||||
var c = new PublicExtensionDataAttributeTestClass
|
||||
{
|
||||
Name = "Name!",
|
||||
ExtensionData = new Dictionary<object, object>
|
||||
{
|
||||
{ "Test", 1 }
|
||||
}
|
||||
};
|
||||
c.ExtensionData["Self"] = c;
|
||||
|
||||
string json = JsonConvert.SerializeObject(c, new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All,
|
||||
Formatting = Formatting.Indented
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""$id"": ""1"",
|
||||
""Name"": ""Name!"",
|
||||
""Test"": 1,
|
||||
""Self"": {
|
||||
""$ref"": ""1""
|
||||
}
|
||||
}", json);
|
||||
|
||||
var c2 = JsonConvert.DeserializeObject<PublicExtensionDataAttributeTestClass>(json, new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All
|
||||
});
|
||||
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
|
||||
PublicExtensionDataAttributeTestClass bizzaroC2 = (PublicExtensionDataAttributeTestClass)c2.ExtensionData["Self"];
|
||||
|
||||
Assert.AreEqual(c2, bizzaroC2);
|
||||
Assert.AreEqual(1, (long)bizzaroC2.ExtensionData["Test"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializePublicJTokenExtensionDataCircularReference()
|
||||
{
|
||||
string json = @"{
|
||||
""$id"": ""1"",
|
||||
""Name"": ""Name!"",
|
||||
""Test"": 1,
|
||||
""Self"": {
|
||||
""$ref"": ""1""
|
||||
}
|
||||
}";
|
||||
|
||||
var c2 = JsonConvert.DeserializeObject<PublicJTokenExtensionDataAttributeTestClass>(json, new JsonSerializerSettings
|
||||
{
|
||||
PreserveReferencesHandling = PreserveReferencesHandling.All
|
||||
});
|
||||
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
|
||||
JObject bizzaroC2 = (JObject)c2.ExtensionData["Self"];
|
||||
|
||||
Assert.AreEqual("Name!", (string)bizzaroC2["Name"]);
|
||||
Assert.AreEqual(1, (int)bizzaroC2["Test"]);
|
||||
|
||||
Assert.AreEqual(1, (int)c2.ExtensionData["Test"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializePublicExtensionDataTypeNamdHandling()
|
||||
{
|
||||
string json = @"{
|
||||
""$id"": ""1"",
|
||||
""Name"": ""Name!"",
|
||||
""Test"": 1,
|
||||
""Self"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
|
||||
""HourlyWage"": 2.0,
|
||||
""Name"": null,
|
||||
""BirthDate"": ""0001-01-01T00:00:00"",
|
||||
""LastModified"": ""0001-01-01T00:00:00""
|
||||
}
|
||||
}";
|
||||
|
||||
PublicExtensionDataAttributeTestClass c2 = JsonConvert.DeserializeObject<PublicExtensionDataAttributeTestClass>(json, new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Objects
|
||||
});
|
||||
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
|
||||
WagePerson bizzaroC2 = (WagePerson)c2.ExtensionData["Self"];
|
||||
|
||||
Assert.AreEqual(2m, bizzaroC2.HourlyWage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializePublicExtensionDataTypeNamdHandlingNonDefaultConstructor()
|
||||
{
|
||||
string json = @"{
|
||||
""$id"": ""1"",
|
||||
""Name"": ""Name!"",
|
||||
""Test"": 1,
|
||||
""Self"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
|
||||
""HourlyWage"": 2.0,
|
||||
""Name"": null,
|
||||
""BirthDate"": ""0001-01-01T00:00:00"",
|
||||
""LastModified"": ""0001-01-01T00:00:00""
|
||||
}
|
||||
}";
|
||||
|
||||
PublicExtensionDataAttributeTestClassWithNonDefaultConstructor c2 = JsonConvert.DeserializeObject<PublicExtensionDataAttributeTestClassWithNonDefaultConstructor>(json, new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Objects
|
||||
});
|
||||
|
||||
Assert.AreEqual("Name!", c2.Name);
|
||||
|
||||
WagePerson bizzaroC2 = (WagePerson)c2.ExtensionData["Self"];
|
||||
|
||||
Assert.AreEqual(2m, bizzaroC2.HourlyWage);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SerializePublicExtensionDataTypeNamdHandling()
|
||||
{
|
||||
PublicExtensionDataAttributeTestClass c = new PublicExtensionDataAttributeTestClass
|
||||
{
|
||||
Name = "Name!",
|
||||
ExtensionData = new Dictionary<object, object>
|
||||
{
|
||||
{
|
||||
"Test", new WagePerson
|
||||
{
|
||||
HourlyWage = 2.1m
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(c, new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.Objects,
|
||||
Formatting = Formatting.Indented
|
||||
});
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.ExtensionDataTests+PublicExtensionDataAttributeTestClass, Newtonsoft.Json.Tests"",
|
||||
""Name"": ""Name!"",
|
||||
""Test"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.WagePerson, Newtonsoft.Json.Tests"",
|
||||
""HourlyWage"": 2.1,
|
||||
""Name"": null,
|
||||
""BirthDate"": ""0001-01-01T00:00:00"",
|
||||
""LastModified"": ""0001-01-01T00:00:00""
|
||||
}
|
||||
}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeserializePublicExtensionData()
|
||||
{
|
||||
string json = @"{
|
||||
'Name':'Name!',
|
||||
'NoMatch':'NoMatch!',
|
||||
'ExtensionData':{'HAI':true}
|
||||
}";
|
||||
|
||||
var c = JsonConvert.DeserializeObject<PublicExtensionDataAttributeTestClass>(json);
|
||||
|
||||
Assert.AreEqual("Name!", c.Name);
|
||||
Assert.AreEqual(2, c.ExtensionData.Count);
|
||||
|
||||
Assert.AreEqual("NoMatch!", (string)c.ExtensionData["NoMatch"]);
|
||||
|
||||
// the ExtensionData property is put into the extension data
|
||||
// inception
|
||||
var o = (JObject)c.ExtensionData["ExtensionData"];
|
||||
Assert.AreEqual(1, o.Count);
|
||||
Assert.IsTrue(JToken.DeepEquals(new JObject { { "HAI", true } }, o));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FieldExtensionDataAttributeTest_Serialize()
|
||||
{
|
||||
FieldExtensionDataAttributeTestClass c = new FieldExtensionDataAttributeTestClass
|
||||
{
|
||||
ExtensionData = new Dictionary<object, object>()
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(c);
|
||||
|
||||
Assert.AreEqual("{}", json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FieldExtensionDataAttributeTest_Deserialize()
|
||||
{
|
||||
var c = JsonConvert.DeserializeObject<FieldExtensionDataAttributeTestClass>("{'first':1,'second':2}");
|
||||
|
||||
Assert.AreEqual(2, c.ExtensionData.Count);
|
||||
Assert.AreEqual(1, (long)c.ExtensionData["first"]);
|
||||
Assert.AreEqual(2, (long)c.ExtensionData["second"]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultipleExtensionDataAttributesTest()
|
||||
{
|
||||
var c = JsonConvert.DeserializeObject<MultipleExtensionDataAttributesTestClass>("{'first':[1],'second':[2]}");
|
||||
|
||||
Assert.AreEqual(null, c.ExtensionData1);
|
||||
Assert.AreEqual(2, c.ExtensionData2.Count);
|
||||
Assert.AreEqual(1, (int)((JArray)c.ExtensionData2["first"])[0]);
|
||||
Assert.AreEqual(2, (int)((JArray)c.ExtensionData2["second"])[0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ExtensionDataAttributesInheritanceTest()
|
||||
{
|
||||
var c = JsonConvert.DeserializeObject<ExtensionDataAttributesInheritanceTestClass>("{'first':1,'second':2}");
|
||||
|
||||
Assert.AreEqual(null, c.ExtensionData1);
|
||||
Assert.AreEqual(null, c.ExtensionData2);
|
||||
Assert.AreEqual(2, c.ExtensionData0.Count);
|
||||
Assert.AreEqual(1, (int)c.ExtensionData0["first"]);
|
||||
Assert.AreEqual(2, (int)c.ExtensionData0["second"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,543 @@
|
||||
#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.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.Serialization
|
||||
{
|
||||
[TestFixture]
|
||||
public class ShouldSerializeTests : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void VirtualShouldSerialize()
|
||||
{
|
||||
var setFoo = new Foo1()
|
||||
{
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myBar = new Bar1()
|
||||
{
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myBaz = new Baz1[] {
|
||||
new Baz1(){
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myFrob = new Frob1[]{
|
||||
new Frob1{name = Guid.NewGuid().ToString()}
|
||||
}
|
||||
},
|
||||
new Baz1(){
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myFrob = new Frob1[]{
|
||||
new Frob1{name = Guid.NewGuid().ToString()}
|
||||
}
|
||||
},
|
||||
new Baz1(){
|
||||
name = Guid.NewGuid().ToString(),
|
||||
myFrob = new Frob1[]{
|
||||
new Frob1{name = Guid.NewGuid().ToString()}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var setFooJson = Serialize(setFoo);
|
||||
var deserializedSetFoo = JsonConvert.DeserializeObject<Foo1>(setFooJson);
|
||||
|
||||
Assert.AreEqual(setFoo.name, deserializedSetFoo.name);
|
||||
Assert.NotNull(deserializedSetFoo.myBar);
|
||||
Assert.AreEqual(setFoo.myBar.name, deserializedSetFoo.myBar.name);
|
||||
Assert.NotNull(deserializedSetFoo.myBar.myBaz);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz.Length, deserializedSetFoo.myBar.myBaz.Length);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz[0].name, deserializedSetFoo.myBar.myBaz[0].name);
|
||||
Assert.IsNotNull(deserializedSetFoo.myBar.myBaz[0].myFrob[0]);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz[0].myFrob[0].name, deserializedSetFoo.myBar.myBaz[0].myFrob[0].name);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz[1].name, deserializedSetFoo.myBar.myBaz[1].name);
|
||||
Assert.IsNotNull(deserializedSetFoo.myBar.myBaz[2].myFrob[0]);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz[1].myFrob[0].name, deserializedSetFoo.myBar.myBaz[1].myFrob[0].name);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz[2].name, deserializedSetFoo.myBar.myBaz[2].name);
|
||||
Assert.IsNotNull(deserializedSetFoo.myBar.myBaz[2].myFrob[0]);
|
||||
Assert.AreEqual(setFoo.myBar.myBaz[2].myFrob[0].name, deserializedSetFoo.myBar.myBaz[2].myFrob[0].name);
|
||||
|
||||
Assert.AreEqual(true, setFoo.myBar.ShouldSerializemyBazCalled);
|
||||
}
|
||||
|
||||
private string Serialize(Foo1 f)
|
||||
{
|
||||
//Code copied from JsonConvert.SerializeObject(), with addition of trace writing
|
||||
JsonSerializer jsonSerializer = JsonSerializer.CreateDefault();
|
||||
var traceWriter = new MemoryTraceWriter();
|
||||
jsonSerializer.TraceWriter = traceWriter;
|
||||
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
StringWriter sw = new StringWriter(sb, CultureInfo.InvariantCulture);
|
||||
using (JsonTextWriter jsonWriter = new JsonTextWriter(sw))
|
||||
{
|
||||
jsonWriter.Formatting = Formatting.None;
|
||||
jsonSerializer.Serialize(jsonWriter, f, typeof(Foo1));
|
||||
}
|
||||
|
||||
Console.Out.WriteLine("Trace output:\n{0}", traceWriter.ToString());
|
||||
|
||||
return sw.ToString();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShouldSerializeTest()
|
||||
{
|
||||
ShouldSerializeTestClass c = new ShouldSerializeTestClass();
|
||||
c.Name = "James";
|
||||
c.Age = 27;
|
||||
|
||||
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""Age"": 27
|
||||
}", json);
|
||||
|
||||
c._shouldSerializeName = true;
|
||||
json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""Name"": ""James"",
|
||||
""Age"": 27
|
||||
}", json);
|
||||
|
||||
ShouldSerializeTestClass deserialized = JsonConvert.DeserializeObject<ShouldSerializeTestClass>(json);
|
||||
Assert.AreEqual("James", deserialized.Name);
|
||||
Assert.AreEqual(27, deserialized.Age);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShouldSerializeExample()
|
||||
{
|
||||
Employee joe = new Employee();
|
||||
joe.Name = "Joe Employee";
|
||||
Employee mike = new Employee();
|
||||
mike.Name = "Mike Manager";
|
||||
|
||||
joe.Manager = mike;
|
||||
mike.Manager = mike;
|
||||
|
||||
string json = JsonConvert.SerializeObject(new[] { joe, mike }, Formatting.Indented);
|
||||
// [
|
||||
// {
|
||||
// "Name": "Joe Employee",
|
||||
// "Manager": {
|
||||
// "Name": "Mike Manager"
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "Name": "Mike Manager"
|
||||
// }
|
||||
// ]
|
||||
|
||||
Console.WriteLine(json);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SpecifiedTest()
|
||||
{
|
||||
SpecifiedTestClass c = new SpecifiedTestClass();
|
||||
c.Name = "James";
|
||||
c.Age = 27;
|
||||
c.NameSpecified = false;
|
||||
|
||||
string json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""Age"": 27
|
||||
}", json);
|
||||
|
||||
SpecifiedTestClass deserialized = JsonConvert.DeserializeObject<SpecifiedTestClass>(json);
|
||||
Assert.IsNull(deserialized.Name);
|
||||
Assert.IsFalse(deserialized.NameSpecified);
|
||||
Assert.IsFalse(deserialized.WeightSpecified);
|
||||
Assert.IsFalse(deserialized.HeightSpecified);
|
||||
Assert.IsFalse(deserialized.FavoriteNumberSpecified);
|
||||
Assert.AreEqual(27, deserialized.Age);
|
||||
|
||||
c.NameSpecified = true;
|
||||
c.WeightSpecified = true;
|
||||
c.HeightSpecified = true;
|
||||
c.FavoriteNumber = 23;
|
||||
json = JsonConvert.SerializeObject(c, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""Name"": ""James"",
|
||||
""Age"": 27,
|
||||
""Weight"": 0,
|
||||
""Height"": 0,
|
||||
""FavoriteNumber"": 23
|
||||
}", json);
|
||||
|
||||
deserialized = JsonConvert.DeserializeObject<SpecifiedTestClass>(json);
|
||||
Assert.AreEqual("James", deserialized.Name);
|
||||
Assert.IsTrue(deserialized.NameSpecified);
|
||||
Assert.IsTrue(deserialized.WeightSpecified);
|
||||
Assert.IsTrue(deserialized.HeightSpecified);
|
||||
Assert.IsTrue(deserialized.FavoriteNumberSpecified);
|
||||
Assert.AreEqual(27, deserialized.Age);
|
||||
Assert.AreEqual(23, deserialized.FavoriteNumber);
|
||||
}
|
||||
|
||||
// [Test]
|
||||
// public void XmlSerializerSpecifiedTrueTest()
|
||||
// {
|
||||
// XmlSerializer s = new XmlSerializer(typeof(OptionalOrder));
|
||||
|
||||
// StringWriter sw = new StringWriter();
|
||||
// s.Serialize(sw, new OptionalOrder() { FirstOrder = "First", FirstOrderSpecified = true });
|
||||
|
||||
// Console.WriteLine(sw.ToString());
|
||||
|
||||
// string xml = @"<?xml version=""1.0"" encoding=""utf-16""?>
|
||||
//<OptionalOrder xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
|
||||
// <FirstOrder>First</FirstOrder>
|
||||
//</OptionalOrder>";
|
||||
|
||||
// OptionalOrder o = (OptionalOrder)s.Deserialize(new StringReader(xml));
|
||||
// Console.WriteLine(o.FirstOrder);
|
||||
// Console.WriteLine(o.FirstOrderSpecified);
|
||||
// }
|
||||
|
||||
// [Test]
|
||||
// public void XmlSerializerSpecifiedFalseTest()
|
||||
// {
|
||||
// XmlSerializer s = new XmlSerializer(typeof(OptionalOrder));
|
||||
|
||||
// StringWriter sw = new StringWriter();
|
||||
// s.Serialize(sw, new OptionalOrder() { FirstOrder = "First", FirstOrderSpecified = false });
|
||||
|
||||
// Console.WriteLine(sw.ToString());
|
||||
|
||||
// // string xml = @"<?xml version=""1.0"" encoding=""utf-16""?>
|
||||
// //<OptionalOrder xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
|
||||
// // <FirstOrder>First</FirstOrder>
|
||||
// //</OptionalOrder>";
|
||||
|
||||
// // OptionalOrder o = (OptionalOrder)s.Deserialize(new StringReader(xml));
|
||||
// // Console.WriteLine(o.FirstOrder);
|
||||
// // Console.WriteLine(o.FirstOrderSpecified);
|
||||
// }
|
||||
|
||||
public class OptionalOrder
|
||||
{
|
||||
// This field shouldn't be serialized
|
||||
// if it is uninitialized.
|
||||
public string FirstOrder;
|
||||
// Use the XmlIgnoreAttribute to ignore the
|
||||
// special field named "FirstOrderSpecified".
|
||||
[System.Xml.Serialization.XmlIgnoreAttribute]
|
||||
public bool FirstOrderSpecified;
|
||||
}
|
||||
|
||||
public class FamilyDetails
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int NumberOfChildren { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool NumberOfChildrenSpecified { get; set; }
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SpecifiedExample()
|
||||
{
|
||||
FamilyDetails joe = new FamilyDetails();
|
||||
joe.Name = "Joe Family Details";
|
||||
joe.NumberOfChildren = 4;
|
||||
joe.NumberOfChildrenSpecified = true;
|
||||
|
||||
FamilyDetails martha = new FamilyDetails();
|
||||
martha.Name = "Martha Family Details";
|
||||
martha.NumberOfChildren = 3;
|
||||
martha.NumberOfChildrenSpecified = false;
|
||||
|
||||
string json = JsonConvert.SerializeObject(new[] { joe, martha }, Formatting.Indented);
|
||||
//[
|
||||
// {
|
||||
// "Name": "Joe Family Details",
|
||||
// "NumberOfChildren": 4
|
||||
// },
|
||||
// {
|
||||
// "Name": "Martha Family Details"
|
||||
// }
|
||||
//]
|
||||
Console.WriteLine(json);
|
||||
|
||||
string mikeString = "{\"Name\": \"Mike Person\"}";
|
||||
FamilyDetails mike = JsonConvert.DeserializeObject<FamilyDetails>(mikeString);
|
||||
|
||||
Console.WriteLine("mikeString specifies number of children: {0}", mike.NumberOfChildrenSpecified);
|
||||
|
||||
string mikeFullDisclosureString = "{\"Name\": \"Mike Person\", \"NumberOfChildren\": \"0\"}";
|
||||
mike = JsonConvert.DeserializeObject<FamilyDetails>(mikeFullDisclosureString);
|
||||
|
||||
Console.WriteLine("mikeString specifies number of children: {0}", mike.NumberOfChildrenSpecified);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ShouldSerializeInheritedClassTest()
|
||||
{
|
||||
NewEmployee joe = new NewEmployee();
|
||||
joe.Name = "Joe Employee";
|
||||
joe.Age = 100;
|
||||
|
||||
Employee mike = new Employee();
|
||||
mike.Name = "Mike Manager";
|
||||
mike.Manager = mike;
|
||||
|
||||
joe.Manager = mike;
|
||||
|
||||
//StringWriter sw = new StringWriter();
|
||||
|
||||
//XmlSerializer x = new XmlSerializer(typeof(NewEmployee));
|
||||
//x.Serialize(sw, joe);
|
||||
|
||||
//Console.WriteLine(sw);
|
||||
|
||||
//JavaScriptSerializer s = new JavaScriptSerializer();
|
||||
//Console.WriteLine(s.Serialize(new {html = @"<script>hi</script>; & ! ^ * ( ) ! @ # $ % ^ ' "" - , . / ; : [ { } ] ; ' - _ = + ? ` ~ \ |"}));
|
||||
|
||||
string json = JsonConvert.SerializeObject(joe, Formatting.Indented);
|
||||
|
||||
Assert.AreEqual(@"{
|
||||
""Age"": 100,
|
||||
""Name"": ""Joe Employee"",
|
||||
""Manager"": {
|
||||
""Name"": ""Mike Manager""
|
||||
}
|
||||
}", json);
|
||||
}
|
||||
|
||||
public class Employee
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public Employee Manager { get; set; }
|
||||
|
||||
public bool ShouldSerializeManager()
|
||||
{
|
||||
return (Manager != this);
|
||||
}
|
||||
}
|
||||
|
||||
public class NewEmployee : Employee
|
||||
{
|
||||
public int Age { get; set; }
|
||||
|
||||
public bool ShouldSerializeName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ShouldSerializeTestClass
|
||||
{
|
||||
internal bool _shouldSerializeName;
|
||||
|
||||
public string Name { get; set; }
|
||||
public int Age { get; set; }
|
||||
|
||||
public void ShouldSerializeAge()
|
||||
{
|
||||
// dummy. should never be used because it doesn't return bool
|
||||
}
|
||||
|
||||
public bool ShouldSerializeName()
|
||||
{
|
||||
return _shouldSerializeName;
|
||||
}
|
||||
}
|
||||
|
||||
public class SpecifiedTestClass
|
||||
{
|
||||
private bool _nameSpecified;
|
||||
|
||||
public string Name { get; set; }
|
||||
public int Age { get; set; }
|
||||
public int Weight { get; set; }
|
||||
public int Height { get; set; }
|
||||
public int FavoriteNumber { get; set; }
|
||||
|
||||
// dummy. should never be used because it isn't of type bool
|
||||
[JsonIgnore]
|
||||
public long AgeSpecified { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool NameSpecified
|
||||
{
|
||||
get { return _nameSpecified; }
|
||||
set { _nameSpecified = value; }
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public bool WeightSpecified;
|
||||
|
||||
[JsonIgnore]
|
||||
[System.Xml.Serialization.XmlIgnoreAttribute]
|
||||
public bool HeightSpecified;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool FavoriteNumberSpecified
|
||||
{
|
||||
// get only example
|
||||
get { return FavoriteNumber != 0; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Foo1
|
||||
{
|
||||
private Bar1 myBarField;
|
||||
public Bar1 myBar
|
||||
{
|
||||
get
|
||||
{
|
||||
return myBarField;
|
||||
}
|
||||
set { myBarField = value; }
|
||||
}
|
||||
|
||||
private string nameField;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return nameField;
|
||||
}
|
||||
set
|
||||
{
|
||||
nameField = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializemyBar()
|
||||
{
|
||||
return (myBar != null);
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializename()
|
||||
{
|
||||
return (name != null);
|
||||
}
|
||||
}
|
||||
|
||||
public class Bar1
|
||||
{
|
||||
[JsonIgnore]
|
||||
public bool ShouldSerializemyBazCalled { get; set;}
|
||||
|
||||
private Baz1[] myBazField;
|
||||
public Baz1[] myBaz
|
||||
{
|
||||
get
|
||||
{
|
||||
return myBazField;
|
||||
}
|
||||
set { myBazField = value; }
|
||||
}
|
||||
|
||||
private string nameField;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return nameField;
|
||||
}
|
||||
set
|
||||
{
|
||||
nameField = value;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializemyBaz()
|
||||
{
|
||||
ShouldSerializemyBazCalled = true;
|
||||
return (myBaz != null);
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializename()
|
||||
{
|
||||
return (name != null);
|
||||
}
|
||||
}
|
||||
|
||||
public class Baz1
|
||||
{
|
||||
private Frob1[] myFrobField;
|
||||
public Frob1[] myFrob
|
||||
{
|
||||
get
|
||||
{
|
||||
return myFrobField;
|
||||
}
|
||||
set { myFrobField = value; }
|
||||
}
|
||||
|
||||
private string nameField;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return nameField;
|
||||
}
|
||||
set { nameField = value; }
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializename()
|
||||
{
|
||||
return (name != null);
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializemyFrob()
|
||||
{
|
||||
return (myFrob != null);
|
||||
}
|
||||
}
|
||||
|
||||
public class Frob1
|
||||
{
|
||||
private string nameField;
|
||||
public string name
|
||||
{
|
||||
get
|
||||
{
|
||||
return nameField;
|
||||
}
|
||||
set { nameField = value; }
|
||||
}
|
||||
|
||||
public virtual bool ShouldSerializename()
|
||||
{
|
||||
return (name != null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1173,7 +1173,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
|
||||
Assert.AreEqual(@"[
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 0
|
||||
},
|
||||
{
|
||||
@@ -1208,7 +1208,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
string json = JsonConvert.SerializeObject(l, Formatting.Indented);
|
||||
Assert.AreEqual(@"{
|
||||
""First"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""Second"": ""String!"",
|
||||
@@ -1238,7 +1238,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
string json = JsonConvert.SerializeObject(o1, Formatting.Indented);
|
||||
string expected = @"{
|
||||
""Object1"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""Object2"": 123,
|
||||
@@ -1279,7 +1279,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
1,
|
||||
""two"",
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
}
|
||||
]
|
||||
@@ -1317,7 +1317,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(@"{
|
||||
""Data"": [
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
{
|
||||
@@ -1342,14 +1342,14 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
json = @"{
|
||||
""Data"": [
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
{
|
||||
""$type"": ""System.Collections.Generic.List`1[[System.Object, mscorlib]], mscorlib"",
|
||||
""$values"": [
|
||||
{
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
}
|
||||
]
|
||||
@@ -1396,7 +1396,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(@"{
|
||||
""Data"": {
|
||||
""one"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""two"": {
|
||||
@@ -1419,13 +1419,13 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
json = @"{
|
||||
""Data"": {
|
||||
""one"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""two"": {
|
||||
""$type"": ""System.Collections.Generic.Dictionary`2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib"",
|
||||
""one"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
}
|
||||
}
|
||||
@@ -1479,7 +1479,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
]
|
||||
},
|
||||
""Prop2"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""Prop3"": 3,
|
||||
@@ -1527,7 +1527,7 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
Assert.AreEqual(@"{
|
||||
""Data"": {
|
||||
""one"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""two"": {
|
||||
@@ -1554,13 +1554,13 @@ namespace Newtonsoft.Json.Tests.Serialization
|
||||
json = @"{
|
||||
""Data"": {
|
||||
""one"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 1
|
||||
},
|
||||
""two"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Linq.DynamicDictionary, Newtonsoft.Json.Tests"",
|
||||
""one"": {
|
||||
""$type"": ""Newtonsoft.Json.Tests.Serialization.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""$type"": ""Newtonsoft.Json.Tests.TestObjects.TestComponentSimple, Newtonsoft.Json.Tests"",
|
||||
""MyProperty"": 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
internal class Aa
|
||||
{
|
||||
public int no;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
#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;
|
||||
#if NET20
|
||||
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
public class AnswerFilterModel
|
||||
{
|
||||
[NonSerialized]
|
||||
private readonly IList answerValues;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the class.
|
||||
/// </summary>
|
||||
public AnswerFilterModel()
|
||||
{
|
||||
answerValues = (from answer in Enum.GetNames(typeof(Antworten))
|
||||
select new SelectListItem { Text = answer, Value = answer, Selected = false })
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether active.
|
||||
/// </summary>
|
||||
public bool Active { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether ja.
|
||||
/// nach bisherigen Antworten.
|
||||
/// </summary>
|
||||
public bool Ja { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether handlungsbedarf.
|
||||
/// </summary>
|
||||
public bool Handlungsbedarf { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether beratungsbedarf.
|
||||
/// </summary>
|
||||
public bool Beratungsbedarf { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether unzutreffend.
|
||||
/// </summary>
|
||||
public bool Unzutreffend { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether unbeantwortet.
|
||||
/// </summary>
|
||||
public bool Unbeantwortet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the answer values.
|
||||
/// </summary>
|
||||
public IEnumerable AnswerValues
|
||||
{
|
||||
get { return answerValues; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public enum Antworten
|
||||
{
|
||||
First,
|
||||
Second
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
internal class Bb : Aa
|
||||
{
|
||||
public new bool no;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NET35 || NET20)
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class Component
|
||||
{
|
||||
[JsonIgnore] // Ignore circular reference
|
||||
public GameObject GameObject { get; set; }
|
||||
|
||||
public Component()
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#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.Runtime.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NET20 || NET35)
|
||||
[DataContract]
|
||||
public class DataContractSerializationAttributesClass
|
||||
{
|
||||
public string NoAttribute { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public string IgnoreDataMemberAttribute { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string DataMemberAttribute { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
[DataMember]
|
||||
public string IgnoreDataMemberAndDataMemberAttribute { get; set; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class DateTimeWrapper
|
||||
{
|
||||
public DateTime Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class DecimalTestClass
|
||||
{
|
||||
public decimal Quantity { get; set; }
|
||||
public double OptionalQuantity { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#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.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class DirectoryAccount
|
||||
{
|
||||
// normal deserialization
|
||||
public string DisplayName { get; set; }
|
||||
|
||||
// these properties are set in OnDeserialized
|
||||
public string UserName { get; set; }
|
||||
public string Domain { get; set; }
|
||||
|
||||
[JsonExtensionData]
|
||||
private IDictionary<string, JToken> _additionalData;
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
// SAMAccountName is not deserialized to any property
|
||||
// and so it is added to the extension data dictionary
|
||||
string samAccountName = (string)_additionalData["SAMAccountName"];
|
||||
|
||||
Domain = samAccountName.Split('\\')[0];
|
||||
UserName = samAccountName.Split('\\')[1];
|
||||
}
|
||||
|
||||
public DirectoryAccount()
|
||||
{
|
||||
_additionalData = new Dictionary<string, JToken>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#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 Newtonsoft.Json.Converters;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class Event1
|
||||
{
|
||||
public string EventName { get; set; }
|
||||
public string Venue { get; set; }
|
||||
|
||||
[JsonProperty(ItemConverterType = typeof(JavaScriptDateTimeConverter))]
|
||||
public IList<DateTime> Performances { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
#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
|
||||
|
||||
#if !(NET35 || NET20)
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class GameObject
|
||||
{
|
||||
[JsonProperty]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public ConcurrentDictionary<string, Component> Components;
|
||||
|
||||
public GameObject()
|
||||
{
|
||||
Components = new ConcurrentDictionary<string, Component>();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
#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.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
#if NET20
|
||||
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NETFX_CORE || NET35 || NET20 || PORTABLE || PORTABLE40)
|
||||
[TypeConverter(typeof(MyInterfaceConverter))]
|
||||
internal interface IMyInterface
|
||||
{
|
||||
string Name { get; }
|
||||
|
||||
string PrintTest();
|
||||
}
|
||||
|
||||
internal class MyInterfaceConverter : TypeConverter
|
||||
{
|
||||
private readonly List<IMyInterface> _writers = new List<IMyInterface>
|
||||
{
|
||||
new ConsoleWriter(),
|
||||
new TraceWriter()
|
||||
};
|
||||
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return destinationType == typeof(string);
|
||||
}
|
||||
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return sourceType == typeof(string);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
return (from w in _writers where w.Name == value.ToString() select w).FirstOrDefault();
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value,
|
||||
Type destinationType)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
return ((IMyInterface)value).Name;
|
||||
}
|
||||
}
|
||||
|
||||
[TypeConverter(typeof(MyInterfaceConverter))]
|
||||
internal class ConsoleWriter : IMyInterface
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get { return "Console Writer"; }
|
||||
}
|
||||
|
||||
public string PrintTest()
|
||||
{
|
||||
return "ConsoleWriter";
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
internal class TraceWriter : IMyInterface
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get { return "Trace Writer"; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public string PrintTest()
|
||||
{
|
||||
return "TraceWriter";
|
||||
}
|
||||
}
|
||||
|
||||
internal class TypeConverterJsonConverter : JsonConverter
|
||||
{
|
||||
private TypeConverter GetConverter(Type type)
|
||||
{
|
||||
var converters = type.GetCustomAttributes(typeof(TypeConverterAttribute), true).Union(
|
||||
from t in type.GetInterfaces()
|
||||
from c in t.GetCustomAttributes(typeof(TypeConverterAttribute), true)
|
||||
select c).Distinct();
|
||||
|
||||
return
|
||||
(from c in converters
|
||||
let converter =
|
||||
(TypeConverter)Activator.CreateInstance(Type.GetType(((TypeConverterAttribute)c).ConverterTypeName))
|
||||
where converter.CanConvertFrom(typeof(string))
|
||||
&& converter.CanConvertTo(typeof(string))
|
||||
select converter)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
var converter = GetConverter(value.GetType());
|
||||
var text = converter.ConvertToInvariantString(value);
|
||||
|
||||
writer.WriteValue(text);
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var converter = GetConverter(objectType);
|
||||
return converter.ConvertFromInvariantString(reader.Value.ToString());
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return GetConverter(objectType) != null;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#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 Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class IdReferenceResolver : IReferenceResolver
|
||||
{
|
||||
private readonly IDictionary<Guid, PersonReference> _people = new Dictionary<Guid, PersonReference>();
|
||||
|
||||
public object ResolveReference(object context, string reference)
|
||||
{
|
||||
Guid id = new Guid(reference);
|
||||
|
||||
PersonReference p;
|
||||
_people.TryGetValue(id, out p);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
public string GetReference(object context, object value)
|
||||
{
|
||||
PersonReference p = (PersonReference)value;
|
||||
_people[p.Id] = p;
|
||||
|
||||
return p.Id.ToString();
|
||||
}
|
||||
|
||||
public bool IsReferenced(object context, object value)
|
||||
{
|
||||
PersonReference p = (PersonReference)value;
|
||||
|
||||
return _people.ContainsKey(p.Id);
|
||||
}
|
||||
|
||||
public void AddReference(object context, string reference, object value)
|
||||
{
|
||||
Guid id = new Guid(reference);
|
||||
|
||||
_people[id] = (PersonReference)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class IntToFloatConverter : JsonConverter
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
writer.WriteValue(Convert.ToDouble(value));
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
return Convert.ToInt32(reader.Value);
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(int);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class Item
|
||||
{
|
||||
public Guid SourceTypeID { get; set; }
|
||||
public Guid BrokerID { get; set; }
|
||||
public double Latitude { get; set; }
|
||||
public double Longitude { get; set; }
|
||||
public DateTime TimeStamp { get; set; }
|
||||
|
||||
[JsonProperty(TypeNameHandling = TypeNameHandling.All)]
|
||||
public object Payload { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#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.Globalization;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class MetroPropertyNameResolver : DefaultContractResolver
|
||||
{
|
||||
protected internal override string ResolvePropertyName(string propertyName)
|
||||
{
|
||||
#if !(NETFX_CORE)
|
||||
return ":::" + propertyName.ToUpper(CultureInfo.InvariantCulture) + ":::";
|
||||
#else
|
||||
return ":::" + propertyName.ToUpper() + ":::";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#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.Globalization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class MetroStringConverter : JsonConverter
|
||||
{
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
#if !(NETFX_CORE)
|
||||
writer.WriteValue(":::" + value.ToString().ToUpper(CultureInfo.InvariantCulture) + ":::");
|
||||
#else
|
||||
writer.WriteValue(":::" + value.ToString().ToUpper() + ":::");
|
||||
#endif
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
string s = (string)reader.Value;
|
||||
if (s == null)
|
||||
return null;
|
||||
|
||||
#if !(NETFX_CORE)
|
||||
return s.ToLower(CultureInfo.InvariantCulture).Trim(new[] { ':' });
|
||||
#else
|
||||
return s.ToLower().Trim(new[] { ':' });
|
||||
#endif
|
||||
}
|
||||
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class NullableGuid
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
internal class ParticipantEntity
|
||||
{
|
||||
private Dictionary<string, string> _properties;
|
||||
|
||||
[JsonConstructor]
|
||||
public ParticipantEntity()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date and time that the participant was created in the CU.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "pa_created", DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)]
|
||||
public DateTimeOffset CreationDate { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the properties of the participant.
|
||||
/// </summary>
|
||||
[JsonProperty(PropertyName = "pa_info")]
|
||||
public Dictionary<string, string> Properties
|
||||
{
|
||||
get { return _properties ?? (_properties = new Dictionary<string, string>()); }
|
||||
set { _properties = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#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.Text;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class PersonReference
|
||||
{
|
||||
internal Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public PersonReference Spouse { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
public class PersonSerializable
|
||||
{
|
||||
public PersonSerializable()
|
||||
{
|
||||
}
|
||||
|
||||
private string _name = "";
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
}
|
||||
|
||||
[NonSerialized]
|
||||
private int _age = 0;
|
||||
|
||||
public int Age
|
||||
{
|
||||
get { return _age; }
|
||||
set { _age = value; }
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class PersonWithPrivateConstructor
|
||||
{
|
||||
private PersonWithPrivateConstructor()
|
||||
{
|
||||
}
|
||||
|
||||
public static PersonWithPrivateConstructor CreatePerson()
|
||||
{
|
||||
return new PersonWithPrivateConstructor();
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public int Age { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#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.Runtime.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NET20 || NET35)
|
||||
public class PocoDataContractSerializationAttributesClass
|
||||
{
|
||||
public string NoAttribute { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
public string IgnoreDataMemberAttribute { get; set; }
|
||||
|
||||
[DataMember]
|
||||
public string DataMemberAttribute { get; set; }
|
||||
|
||||
[IgnoreDataMember]
|
||||
[DataMember]
|
||||
public string IgnoreDataMemberAndDataMemberAttribute { get; set; }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
#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.Collections.Generic;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class PropertyItemConverter
|
||||
{
|
||||
[JsonProperty(ItemConverterType = typeof(MetroStringConverter))]
|
||||
public IList<string> Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
#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.Globalization;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !NETFX_CORE
|
||||
public struct Ratio : IConvertible, IFormattable, ISerializable
|
||||
{
|
||||
private readonly int _numerator;
|
||||
private readonly int _denominator;
|
||||
|
||||
public Ratio(int numerator, int denominator)
|
||||
{
|
||||
_numerator = numerator;
|
||||
_denominator = denominator;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
public int Numerator
|
||||
{
|
||||
get { return _numerator; }
|
||||
}
|
||||
|
||||
public int Denominator
|
||||
{
|
||||
get { return _denominator; }
|
||||
}
|
||||
|
||||
public bool IsNan
|
||||
{
|
||||
get { return _denominator == 0; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Serialization operations
|
||||
public Ratio(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
_numerator = info.GetInt32("n");
|
||||
_denominator = info.GetInt32("d");
|
||||
}
|
||||
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||
{
|
||||
info.AddValue("n", _numerator);
|
||||
info.AddValue("d", _denominator);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IConvertible Members
|
||||
public TypeCode GetTypeCode()
|
||||
{
|
||||
return TypeCode.Object;
|
||||
}
|
||||
|
||||
public bool ToBoolean(IFormatProvider provider)
|
||||
{
|
||||
return _numerator == 0;
|
||||
}
|
||||
|
||||
public byte ToByte(IFormatProvider provider)
|
||||
{
|
||||
return (byte)(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public char ToChar(IFormatProvider provider)
|
||||
{
|
||||
return Convert.ToChar(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public DateTime ToDateTime(IFormatProvider provider)
|
||||
{
|
||||
return Convert.ToDateTime(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public decimal ToDecimal(IFormatProvider provider)
|
||||
{
|
||||
return (decimal)_numerator / _denominator;
|
||||
}
|
||||
|
||||
public double ToDouble(IFormatProvider provider)
|
||||
{
|
||||
return _denominator == 0
|
||||
? double.NaN
|
||||
: (double)_numerator / _denominator;
|
||||
}
|
||||
|
||||
public short ToInt16(IFormatProvider provider)
|
||||
{
|
||||
return (short)(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public int ToInt32(IFormatProvider provider)
|
||||
{
|
||||
return _numerator / _denominator;
|
||||
}
|
||||
|
||||
public long ToInt64(IFormatProvider provider)
|
||||
{
|
||||
return _numerator / _denominator;
|
||||
}
|
||||
|
||||
public sbyte ToSByte(IFormatProvider provider)
|
||||
{
|
||||
return (sbyte)(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public float ToSingle(IFormatProvider provider)
|
||||
{
|
||||
return _denominator == 0
|
||||
? float.NaN
|
||||
: (float)_numerator / _denominator;
|
||||
}
|
||||
|
||||
public string ToString(IFormatProvider provider)
|
||||
{
|
||||
return _denominator == 1
|
||||
? _numerator.ToString(provider)
|
||||
: _numerator.ToString(provider) + "/" + _denominator.ToString(provider);
|
||||
}
|
||||
|
||||
public object ToType(Type conversionType, IFormatProvider provider)
|
||||
{
|
||||
return Convert.ChangeType(ToDouble(provider), conversionType, provider);
|
||||
}
|
||||
|
||||
public ushort ToUInt16(IFormatProvider provider)
|
||||
{
|
||||
return (ushort)(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public uint ToUInt32(IFormatProvider provider)
|
||||
{
|
||||
return (uint)(_numerator / _denominator);
|
||||
}
|
||||
|
||||
public ulong ToUInt64(IFormatProvider provider)
|
||||
{
|
||||
return (ulong)(_numerator / _denominator);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region String operations
|
||||
public override string ToString()
|
||||
{
|
||||
return ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public string ToString(string format, IFormatProvider formatProvider)
|
||||
{
|
||||
return ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static Ratio Parse(string input)
|
||||
{
|
||||
return Parse(input, CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
public static Ratio Parse(string input, IFormatProvider formatProvider)
|
||||
{
|
||||
Ratio result;
|
||||
if (!TryParse(input, formatProvider, out result))
|
||||
{
|
||||
throw new FormatException(
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Text '{0}' is invalid text representation of ratio",
|
||||
input));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool TryParse(string input, out Ratio result)
|
||||
{
|
||||
return TryParse(input, CultureInfo.InvariantCulture, out result);
|
||||
}
|
||||
|
||||
public static bool TryParse(string input, IFormatProvider formatProvider, out Ratio result)
|
||||
{
|
||||
if (input != null)
|
||||
{
|
||||
var fractionIndex = input.IndexOf('/');
|
||||
|
||||
int numerator;
|
||||
if (fractionIndex < 0)
|
||||
{
|
||||
if (int.TryParse(input, NumberStyles.Integer, formatProvider, out numerator))
|
||||
{
|
||||
result = new Ratio(numerator, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int denominator;
|
||||
if (int.TryParse(input.Substring(0, fractionIndex), NumberStyles.Integer, formatProvider, out numerator) &&
|
||||
int.TryParse(input.Substring(fractionIndex + 1), NumberStyles.Integer, formatProvider, out denominator))
|
||||
{
|
||||
result = new Ratio(numerator, denominator);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = default(Ratio);
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
[JsonObject(ItemRequired = Required.Always)]
|
||||
public class RequiredObject
|
||||
{
|
||||
public int? NonAttributeProperty { get; set; }
|
||||
|
||||
[JsonProperty]
|
||||
public int? UnsetProperty { get; set; }
|
||||
|
||||
[JsonProperty(Required = Required.Default)]
|
||||
public int? DefaultProperty { get; set; }
|
||||
|
||||
[JsonProperty(Required = Required.AllowNull)]
|
||||
public int? AllowNullProperty { get; set; }
|
||||
|
||||
[JsonProperty(Required = Required.Always)]
|
||||
public int? AlwaysProperty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class SelectListItem
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public string Value { get; set; }
|
||||
public bool Selected { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
#if !(NET35 || NET20)
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class TestComponent : Component
|
||||
{
|
||||
[JsonProperty]
|
||||
public int MyProperty { get; set; }
|
||||
|
||||
public TestComponent()
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class TestComponentSimple
|
||||
{
|
||||
[JsonProperty]
|
||||
public int MyProperty { get; set; }
|
||||
|
||||
public TestComponentSimple()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class TestObject
|
||||
{
|
||||
public TestObject()
|
||||
{
|
||||
}
|
||||
|
||||
public TestObject(string name, byte[] data)
|
||||
{
|
||||
Name = name;
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
public byte[] Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class UriGuidTimeSpanTestClass
|
||||
{
|
||||
public Guid Guid { get; set; }
|
||||
public Guid? NullableGuid { get; set; }
|
||||
public TimeSpan TimeSpan { get; set; }
|
||||
public TimeSpan? NullableTimeSpan { get; set; }
|
||||
public Uri Uri { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class Widget
|
||||
{
|
||||
public WidgetId? Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class Widget1
|
||||
{
|
||||
public WidgetId1? Id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public struct WidgetId
|
||||
{
|
||||
public string Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
[JsonConverter(typeof(WidgetIdJsonConverter))]
|
||||
public struct WidgetId1
|
||||
{
|
||||
public long Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#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;
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class WidgetIdJsonConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type objectType)
|
||||
{
|
||||
return objectType == typeof(WidgetId1) || objectType == typeof(WidgetId1?);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
WidgetId1 id = (WidgetId1)value;
|
||||
writer.WriteValue(id.Value.ToString());
|
||||
}
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null)
|
||||
return null;
|
||||
return new WidgetId1 { Value = int.Parse(reader.Value.ToString()) };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#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
|
||||
|
||||
namespace Newtonsoft.Json.Tests.TestObjects
|
||||
{
|
||||
public class WithEnums
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public MyEnum? NullableEnum { get; set; }
|
||||
}
|
||||
|
||||
public enum MyEnum
|
||||
{
|
||||
Value1,
|
||||
Value2,
|
||||
Value3
|
||||
}
|
||||
}
|
||||
@@ -146,6 +146,7 @@ namespace Newtonsoft.Json.Converters
|
||||
#else
|
||||
attributes = objectType.GetTypeInfo().GetCustomAttributes(true).ToArray();
|
||||
#endif
|
||||
|
||||
bool isFSharpType = false;
|
||||
foreach (object attribute in attributes)
|
||||
{
|
||||
|
||||
@@ -642,7 +642,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous serialize operation. The value of the <c>TResult</c> parameter contains a JSON string representation of the object.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => SerializeObject(value))")]
|
||||
[ObsoleteAttribute("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.SerializeObject(value))")]
|
||||
public static Task<string> SerializeObjectAsync(object value)
|
||||
{
|
||||
return SerializeObjectAsync(value, Formatting.None, null);
|
||||
@@ -657,7 +657,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous serialize operation. The value of the <c>TResult</c> parameter contains a JSON string representation of the object.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => SerializeObject(value, formatting))")]
|
||||
[ObsoleteAttribute("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.SerializeObject(value, formatting))")]
|
||||
public static Task<string> SerializeObjectAsync(object value, Formatting formatting)
|
||||
{
|
||||
return SerializeObjectAsync(value, formatting, null);
|
||||
@@ -674,7 +674,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous serialize operation. The value of the <c>TResult</c> parameter contains a JSON string representation of the object.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => SerializeObject(value, formatting, settings))")]
|
||||
[ObsoleteAttribute("SerializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to serialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.SerializeObject(value, formatting, settings))")]
|
||||
public static Task<string> SerializeObjectAsync(object value, Formatting formatting, JsonSerializerSettings settings)
|
||||
{
|
||||
return Task.Factory.StartNew(() => SerializeObject(value, formatting, settings));
|
||||
@@ -844,7 +844,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous deserialize operation. The value of the <c>TResult</c> parameter contains the deserialized object from the JSON string.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => DeserializeObject<T>(value))")]
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject<T>(value))")]
|
||||
public static Task<T> DeserializeObjectAsync<T>(string value)
|
||||
{
|
||||
return DeserializeObjectAsync<T>(value, null);
|
||||
@@ -863,7 +863,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous deserialize operation. The value of the <c>TResult</c> parameter contains the deserialized object from the JSON string.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => DeserializeObject<T>(value, settings))")]
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject<T>(value, settings))")]
|
||||
public static Task<T> DeserializeObjectAsync<T>(string value, JsonSerializerSettings settings)
|
||||
{
|
||||
return Task.Factory.StartNew(() => DeserializeObject<T>(value, settings));
|
||||
@@ -877,7 +877,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous deserialize operation. The value of the <c>TResult</c> parameter contains the deserialized object from the JSON string.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => DeserializeObject(value))")]
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject(value))")]
|
||||
public static Task<object> DeserializeObjectAsync(string value)
|
||||
{
|
||||
return DeserializeObjectAsync(value, null, null);
|
||||
@@ -896,7 +896,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous deserialize operation. The value of the <c>TResult</c> parameter contains the deserialized object from the JSON string.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => DeserializeObject(value, type, settings))")]
|
||||
[ObsoleteAttribute("DeserializeObjectAsync is obsolete. Use the Task.Factory.StartNew method to deserialize JSON asynchronously: Task.Factory.StartNew(() => JsonConvert.DeserializeObject(value, type, settings))")]
|
||||
public static Task<object> DeserializeObjectAsync(string value, Type type, JsonSerializerSettings settings)
|
||||
{
|
||||
return Task.Factory.StartNew(() => DeserializeObject(value, type, settings));
|
||||
@@ -949,7 +949,7 @@ namespace Newtonsoft.Json
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous populate operation.
|
||||
/// </returns>
|
||||
[ObsoleteAttribute("PopulateObjectAsync is obsolete. Use the Task.Factory.StartNew method to populate an object with JSON values asynchronously: Task.Factory.StartNew(() => PopulateObject(value, target, settings))")]
|
||||
[ObsoleteAttribute("PopulateObjectAsync is obsolete. Use the Task.Factory.StartNew method to populate an object with JSON values asynchronously: Task.Factory.StartNew(() => JsonConvert.PopulateObject(value, target, settings))")]
|
||||
public static Task PopulateObjectAsync(string value, object target, JsonSerializerSettings settings)
|
||||
{
|
||||
return Task.Factory.StartNew(() => PopulateObject(value, target, settings));
|
||||
|
||||
@@ -822,7 +822,7 @@ namespace Newtonsoft.Json
|
||||
{
|
||||
const double epsilon = 2.2204460492503131e-016;
|
||||
|
||||
return Math.Abs(value) < 10.0 * epsilon;
|
||||
return Math.Abs(value) < 20.0 * epsilon;
|
||||
}
|
||||
|
||||
private void ValidatePropertyName(JsonSchemaModel schema)
|
||||
|
||||
@@ -41,7 +41,6 @@ using System.Globalization;
|
||||
using Newtonsoft.Json.Utilities.LinqBridge;
|
||||
#else
|
||||
using System.Linq;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Newtonsoft.Json.Linq
|
||||
|
||||
@@ -91,5 +91,5 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("6.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("6.0.1.17117")]
|
||||
[assembly: AssemblyFileVersion("6.0.1.17131")]
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Newtonsoft.Json.Utilities
|
||||
|
||||
if (method.IsConstructor)
|
||||
generator.Emit(OpCodes.Newobj, (ConstructorInfo)method);
|
||||
else if (method.IsFinal || !method.IsVirtual)
|
||||
else
|
||||
generator.CallMethod((MethodInfo)method);
|
||||
|
||||
Type returnType = method.IsConstructor
|
||||
|
||||
@@ -35,6 +35,8 @@ namespace Newtonsoft.Json.Utilities
|
||||
{
|
||||
internal static class FSharpUtils
|
||||
{
|
||||
private static readonly object Lock = new object();
|
||||
|
||||
private static bool _initialized;
|
||||
private static MethodInfo _ofSeq;
|
||||
|
||||
@@ -56,36 +58,42 @@ namespace Newtonsoft.Json.Utilities
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
FSharpCoreAssembly = fsharpCoreAssembly;
|
||||
lock (Lock)
|
||||
{
|
||||
if (!_initialized)
|
||||
{
|
||||
FSharpCoreAssembly = fsharpCoreAssembly;
|
||||
|
||||
Type fsharpType = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpType");
|
||||
Type fsharpType = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpType");
|
||||
|
||||
MethodInfo isUnionMethodInfo = fsharpType.GetMethod("IsUnion", BindingFlags.Public | BindingFlags.Static);
|
||||
IsUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(isUnionMethodInfo);
|
||||
MethodInfo isUnionMethodInfo = fsharpType.GetMethod("IsUnion", BindingFlags.Public | BindingFlags.Static);
|
||||
IsUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(isUnionMethodInfo);
|
||||
|
||||
MethodInfo getUnionCasesMethodInfo = fsharpType.GetMethod("GetUnionCases", BindingFlags.Public | BindingFlags.Static);
|
||||
GetUnionCases = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(getUnionCasesMethodInfo);
|
||||
MethodInfo getUnionCasesMethodInfo = fsharpType.GetMethod("GetUnionCases", BindingFlags.Public | BindingFlags.Static);
|
||||
GetUnionCases = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(getUnionCasesMethodInfo);
|
||||
|
||||
Type fsharpValue = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpValue");
|
||||
Type fsharpValue = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.FSharpValue");
|
||||
|
||||
MethodInfo getUnionFieldsMethodInfo = fsharpValue.GetMethod("GetUnionFields", BindingFlags.Public | BindingFlags.Static);
|
||||
GetUnionFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(getUnionFieldsMethodInfo);
|
||||
MethodInfo getUnionFieldsMethodInfo = fsharpValue.GetMethod("GetUnionFields", BindingFlags.Public | BindingFlags.Static);
|
||||
GetUnionFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(getUnionFieldsMethodInfo);
|
||||
|
||||
GetUnionCaseInfo = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(getUnionFieldsMethodInfo.ReturnType.GetProperty("Item1"));
|
||||
GetUnionCaseFields = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(getUnionFieldsMethodInfo.ReturnType.GetProperty("Item2"));
|
||||
GetUnionCaseInfo = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(getUnionFieldsMethodInfo.ReturnType.GetProperty("Item1"));
|
||||
GetUnionCaseFields = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(getUnionFieldsMethodInfo.ReturnType.GetProperty("Item2"));
|
||||
|
||||
MethodInfo makeUnionMethodInfo = fsharpValue.GetMethod("MakeUnion", BindingFlags.Public | BindingFlags.Static);
|
||||
MakeUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(makeUnionMethodInfo);
|
||||
MethodInfo makeUnionMethodInfo = fsharpValue.GetMethod("MakeUnion", BindingFlags.Public | BindingFlags.Static);
|
||||
MakeUnion = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(makeUnionMethodInfo);
|
||||
|
||||
Type unionCaseInfo = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.UnionCaseInfo");
|
||||
Type unionCaseInfo = fsharpCoreAssembly.GetType("Microsoft.FSharp.Reflection.UnionCaseInfo");
|
||||
|
||||
GetUnionCaseInfoName = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(unionCaseInfo.GetProperty("Name"));
|
||||
GetUnionCaseInfoFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(unionCaseInfo.GetMethod("GetFields"));
|
||||
GetUnionCaseInfoName = JsonTypeReflector.ReflectionDelegateFactory.CreateGet<object>(unionCaseInfo.GetProperty("Name"));
|
||||
GetUnionCaseInfoFields = JsonTypeReflector.ReflectionDelegateFactory.CreateMethodCall<object>(unionCaseInfo.GetMethod("GetFields"));
|
||||
|
||||
Type listModule = fsharpCoreAssembly.GetType("Microsoft.FSharp.Collections.ListModule");
|
||||
_ofSeq = listModule.GetMethod("OfSeq");
|
||||
Type listModule = fsharpCoreAssembly.GetType("Microsoft.FSharp.Collections.ListModule");
|
||||
_ofSeq = listModule.GetMethod("OfSeq");
|
||||
|
||||
_initialized = true;
|
||||
_initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -616,6 +616,9 @@ namespace Newtonsoft.Json.Utilities
|
||||
IList<MemberInfo> resolvedMembers = new List<MemberInfo>();
|
||||
foreach (MemberInfo memberInfo in members)
|
||||
{
|
||||
// this is a bit hacky
|
||||
// if the hiding property is hiding a base property and it is virtual
|
||||
// then this ensures the derived property gets used
|
||||
if (resolvedMembers.Count == 0)
|
||||
resolvedMembers.Add(memberInfo);
|
||||
else if (!IsOverridenGenericMember(memberInfo, bindingAttr) || memberInfo.Name == "Item")
|
||||
|
||||
Reference in New Issue
Block a user