Skip to content

Commit 759aece

Browse files
committed
- initial commit
0 parents  commit 759aece

22 files changed

+671
-0
lines changed

.gitignore

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
.vs
2+
3+
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
4+
[Bb]in/
5+
[Oo]bj/
6+
[Dd]eployment
7+
.vs
8+
9+
# mstest test results
10+
TestResults
11+
12+
## Ignore Visual Studio temporary files, build results, and
13+
## files generated by popular Visual Studio add-ons.
14+
15+
# User-specific files
16+
*.suo
17+
*.user
18+
*.sln.docstates
19+
20+
# Build results
21+
[Dd]ebug/
22+
[Rr]elease/
23+
x64/
24+
*_i.c
25+
*_p.c
26+
*.ilk
27+
*.meta
28+
*.obj
29+
*.pch
30+
*.pdb
31+
*.pgc
32+
*.pgd
33+
*.rsp
34+
*.sbr
35+
*.tlb
36+
*.tli
37+
*.tlh
38+
*.tmp
39+
*.log
40+
*.vspscc
41+
*.vssscc
42+
.builds
43+
44+
# Visual C++ cache files
45+
ipch/
46+
*.aps
47+
*.ncb
48+
*.opensdf
49+
*.sdf
50+
51+
# Visual Studio profiler
52+
*.psess
53+
*.vsp
54+
*.vspx
55+
56+
# Guidance Automation Toolkit
57+
*.gpState
58+
59+
# ReSharper is a .NET coding add-in
60+
_ReSharper*/
61+
*.[Rr]e[Ss]harper
62+
*.DotSettings.user
63+
*.DotSettings
64+
65+
# NCrunch
66+
*.ncrunch*
67+
.*crunch*.local.xml
68+
69+
# Installshield output folder
70+
[Ee]xpress
71+
72+
# DocProject is a documentation generator add-in
73+
DocProject/buildhelp/
74+
DocProject/Help/*.HxT
75+
DocProject/Help/*.HxC
76+
DocProject/Help/*.hhc
77+
DocProject/Help/*.hhk
78+
DocProject/Help/*.hhp
79+
DocProject/Help/Html2
80+
DocProject/Help/html
81+
82+
# Click-Once directory
83+
publish
84+
85+
# Publish Web Output
86+
*.Publish.xml
87+
88+
# NuGet Packages Directory
89+
packages
90+
91+
# Windows Azure Build Output
92+
csx
93+
*.build.csdef
94+
95+
# Windows Store app package directory
96+
AppPackages/
97+
98+
# Others
99+
[Bb]in
100+
[Oo]bj
101+
sql
102+
TestResults
103+
[Tt]est[Rr]esult*
104+
*.Cache
105+
ClientBin
106+
[Ss]tyle[Cc]op.*
107+
~$*
108+
*.dbmdl
109+
Generated_Code #added for RIA/Silverlight projects
110+
111+
# Backup & report files from converting an old project file to a newer
112+
# Visual Studio version. Backup files are not needed, because we have git ;-)
113+
_UpgradeReport_Files/
114+
Backup*/
115+
UpgradeLog*.XML

.media/logo.png

17.9 KB
Loading

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2018, Eben Roux
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
Redistributions in binary form must reproduce the above copyright notice, this
11+
list of conditions and the following disclaimer in the documentation and/or
12+
other materials provided with the distribution.
13+
14+
Neither the name of the Shuttle organization nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Shuttle.Core.Serialization
2+
3+
Provides an `ISerialization` adapter interface with a `DefaultSerializer` implementation.
4+
5+
Visit the [documentation site](http://shuttle.github.io/shuttle-core/).
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
3+
namespace Shuttle.Core.Serialization.Tests
4+
{
5+
public class ComplexSerializerType
6+
{
7+
public ComplexSerializerType()
8+
{
9+
Id = Guid.NewGuid();
10+
SomeSerializerType1 = new v1.SomeSerializerType();
11+
AnotherSerializerType1 = new v1.AnotherSerializerType();
12+
SomeSerializerType2 = new v2.SomeSerializerType();
13+
AnotherSerializerType2 = new v2.AnotherSerializerType();
14+
}
15+
16+
public Guid Id { get; set; }
17+
public v1.SomeSerializerType SomeSerializerType1 { get; set; }
18+
public v1.AnotherSerializerType AnotherSerializerType1 { get; set; }
19+
public v2.SomeSerializerType SomeSerializerType2 { get; set; }
20+
public v2.AnotherSerializerType AnotherSerializerType2 { get; set; }
21+
}
22+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using System;
2+
using System.IO;
3+
using NUnit.Framework;
4+
5+
namespace Shuttle.Core.Serialization.Tests
6+
{
7+
public class DefaultSerializerFixture
8+
{
9+
[Test]
10+
public void Should_be_able_to_serialize_and_deserialize_a_simple_type()
11+
{
12+
var original = new SimpleSerializerType();
13+
var serializer = new DefaultSerializer();
14+
15+
var stream = serializer.Serialize(original);
16+
17+
var xml = new StreamReader(stream).ReadToEnd();
18+
19+
Assert.IsTrue(xml.Contains(original.Id.ToString()));
20+
21+
stream.Position = 0;
22+
23+
Assert.AreEqual(original.Id, ((SimpleSerializerType) serializer.Deserialize(typeof (SimpleSerializerType), stream)).Id);
24+
}
25+
26+
[Test]
27+
public void Should_be_able_to_serialize_and_deserialize_a_complex_type()
28+
{
29+
var complex = new ComplexSerializerType();
30+
var serializer = new DefaultSerializer();
31+
32+
serializer.AddSerializerType(typeof(ComplexSerializerType), typeof(v1.SomeSerializerType));
33+
serializer.AddSerializerType(typeof(ComplexSerializerType), typeof(v1.AnotherSerializerType));
34+
serializer.AddSerializerType(typeof(ComplexSerializerType), typeof(v2.SomeSerializerType));
35+
serializer.AddSerializerType(typeof(ComplexSerializerType), typeof(v2.AnotherSerializerType));
36+
37+
var stream = serializer.Serialize(complex);
38+
var xml = new StreamReader(stream).ReadToEnd();
39+
40+
Assert.IsTrue(xml.Contains(complex.Id.ToString()));
41+
42+
stream.Position = 0;
43+
44+
Assert.AreEqual(complex.Id, ((ComplexSerializerType) serializer.Deserialize(typeof (ComplexSerializerType), stream)).Id);
45+
46+
Console.WriteLine(xml);
47+
48+
var some1 = new v1.SomeSerializerType();
49+
var some2 = new v2.SomeSerializerType();
50+
51+
Assert.AreEqual(some1.Id, ((v1.SomeSerializerType)serializer.Deserialize(typeof(v1.SomeSerializerType), serializer.Serialize(some1))).Id);
52+
Assert.AreEqual(some2.Id, ((v2.SomeSerializerType)serializer.Deserialize(typeof(v2.SomeSerializerType), serializer.Serialize(some2))).Id);
53+
}
54+
}
55+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
9+
<PackageReference Include="NUnit" Version="3.9.0" />
10+
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<ProjectReference Include="..\Shuttle.Core.Serialization\Shuttle.Core.Serialization.csproj" />
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace Shuttle.Core.Serialization.Tests
4+
{
5+
public class SimpleSerializerType
6+
{
7+
public Guid Id { get; set; }
8+
}
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
3+
namespace Shuttle.Core.Serialization.Tests.v1
4+
{
5+
public class AnotherSerializerType
6+
{
7+
public AnotherSerializerType()
8+
{
9+
Id = Guid.NewGuid();
10+
}
11+
12+
public Guid Id { get; set; }
13+
}
14+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
3+
namespace Shuttle.Core.Serialization.Tests.v1
4+
{
5+
public class SomeSerializerType
6+
{
7+
public SomeSerializerType()
8+
{
9+
Id = Guid.NewGuid();
10+
AnotherSerializerType = new AnotherSerializerType();
11+
}
12+
13+
public Guid Id { get; set; }
14+
public AnotherSerializerType AnotherSerializerType { get; set; }
15+
}
16+
}

0 commit comments

Comments
 (0)