Skip to content
This repository was archived by the owner on Mar 14, 2023. It is now read-only.

Commit 3058106

Browse files
committed
init
1 parent 0586a13 commit 3058106

206 files changed

Lines changed: 17366 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#################
2+
## Visual Studio
3+
#################
4+
5+
## Ignore Visual Studio temporary files, build results, and
6+
## files generated by popular Visual Studio add-ons.
7+
8+
# User-specific files
9+
*.suo
10+
*.user
11+
*.sln.docstates
12+
*.pidb
13+
*.ncrunchsolution
14+
*.ncrunchproject
15+
*.DotSettings
16+
17+
# Build results
18+
[Dd]ebug/
19+
[Rr]elease/
20+
*_i.c
21+
*_p.c
22+
*.ilk
23+
*.meta
24+
*.obj
25+
*.pch
26+
*.pgc
27+
*.pgd
28+
*.rsp
29+
*.sbr
30+
*.tlb
31+
*.tli
32+
*.tlh
33+
*.tmp
34+
*.vspscc
35+
.builds
36+
*.dotCover
37+
*test-results*
38+
39+
40+
## If you have NuGet Package Restore enabled, uncomment this
41+
packages/
42+
ForSample/
43+
NugetBuild/
44+
NuGetBuildCodeOnly/
45+
ChocolateyNuGetBuild/
46+
NuGetTracingBuild/
47+
48+
# Visual Studio profiler
49+
*.psess
50+
*.vsp
51+
52+
# ReSharper is a .NET coding add-in
53+
_ReSharper*
54+
55+
# Others
56+
[Bb]in
57+
[Oo]bj
58+
sql
59+
TestResults
60+
*.Cache
61+
ClientBin
62+
stylecop.*
63+
~$*
64+
*.dbmdl
65+
Generated_Code #added for RIA/Silverlight projects
66+
67+
# Backup & report files from converting an old project file to a newer
68+
# Visual Studio version. Backup files are not needed, because we have git ;-)
69+
_UpgradeReport_Files/
70+
Backup*/
71+
UpgradeLog*.XML
72+
73+
74+
############
75+
## Windows
76+
############
77+
78+
# Windows image file caches
79+
Thumbs.db
80+
81+
# Folder config file
82+
Desktop.ini
83+
84+
85+
Fody/.DS_Store
86+
87+
.DS_Store
88+
89+
*.userprefs

LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015, Igal Tabachnik
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

NSBHyperion.sln

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.26403.7
4+
MinimumVisualStudioVersion = 15.0.26403.0
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.Hyperion", "NServiceBus.Hyperion\NServiceBus.Hyperion.csproj", "{29ED7A0C-9A61-4416-A020-AAB1E1C5C743}"
6+
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{D1C231FA-FFF6-4B8A-AFEE-DABD7F8324E3}"
8+
EndProject
9+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{B4AD5761-3E58-42EE-AD76-AE13E6E2213B}"
10+
EndProject
11+
Global
12+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
13+
Debug|Any CPU = Debug|Any CPU
14+
Release|Any CPU = Release|Any CPU
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{29ED7A0C-9A61-4416-A020-AAB1E1C5C743}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{29ED7A0C-9A61-4416-A020-AAB1E1C5C743}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{29ED7A0C-9A61-4416-A020-AAB1E1C5C743}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{29ED7A0C-9A61-4416-A020-AAB1E1C5C743}.Release|Any CPU.Build.0 = Release|Any CPU
21+
{D1C231FA-FFF6-4B8A-AFEE-DABD7F8324E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
22+
{D1C231FA-FFF6-4B8A-AFEE-DABD7F8324E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
23+
{D1C231FA-FFF6-4B8A-AFEE-DABD7F8324E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
24+
{D1C231FA-FFF6-4B8A-AFEE-DABD7F8324E3}.Release|Any CPU.Build.0 = Release|Any CPU
25+
{B4AD5761-3E58-42EE-AD76-AE13E6E2213B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{B4AD5761-3E58-42EE-AD76-AE13E6E2213B}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{B4AD5761-3E58-42EE-AD76-AE13E6E2213B}.Release|Any CPU.ActiveCfg = Release|Any CPU
28+
{B4AD5761-3E58-42EE-AD76-AE13E6E2213B}.Release|Any CPU.Build.0 = Release|Any CPU
29+
EndGlobalSection
30+
GlobalSection(SolutionProperties) = preSolution
31+
HideSolutionNode = FALSE
32+
EndGlobalSection
33+
EndGlobal
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
using System.Reflection;
2+
3+
[assembly: AssemblyTitle("NServiceBus.Hyperion")]
4+
[assembly: AssemblyProduct("NServiceBus.Hyperion")]
5+
[assembly: AssemblyVersion("0.1.0")]
6+
[assembly: AssemblyFileVersion("0.1.0")]

NServiceBus.Hyperion/Guard.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
3+
static class Guard
4+
{
5+
6+
// ReSharper disable UnusedParameter.Global
7+
public static void AgainstNull(object value, string argumentName)
8+
{
9+
if (value == null)
10+
{
11+
throw new ArgumentNullException(argumentName);
12+
}
13+
}
14+
15+
public static void AgainstNullOrEmpty(string value, string argumentName)
16+
{
17+
if (string.IsNullOrWhiteSpace(value))
18+
{
19+
throw new ArgumentNullException(argumentName);
20+
}
21+
}
22+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using Hyperion;
2+
using NServiceBus.Configuration.AdvanceExtensibility;
3+
using NServiceBus.Serialization;
4+
using NServiceBus.Settings;
5+
using NServiceBus.Hyperion;
6+
7+
namespace NServiceBus
8+
{
9+
10+
/// <summary>
11+
/// Extensions for <see cref="SerializationExtensions{T}"/> to manipulate how messages are serialized via Jil.
12+
/// </summary>
13+
public static class HyperionConfigurationExtensions
14+
{
15+
16+
/// <summary>
17+
/// Configures the <see cref="SerializerOptions"/> to use.
18+
/// </summary>
19+
/// <param name="config">The <see cref="SerializationExtensions{T}"/> instance.</param>
20+
/// <param name="options">The <see cref="SerializerOptions"/> to use.</param>
21+
public static void Options(this SerializationExtensions<HyperionSerializer> config, SerializerOptions options)
22+
{
23+
Guard.AgainstNull(config, nameof(config));
24+
var settings = config.GetSettings();
25+
settings.Set<SerializerOptions>(options);
26+
}
27+
28+
internal static SerializerOptions GetOptions(this ReadOnlySettings settings)
29+
{
30+
return settings.GetOrDefault<SerializerOptions>();
31+
}
32+
33+
/// <summary>
34+
/// Configures string to use for <see cref="Headers.ContentType"/> headers.
35+
/// </summary>
36+
/// <remarks>
37+
/// Defaults to "hyperion".
38+
/// </remarks>
39+
/// <param name="config">The <see cref="SerializationExtensions{T}"/> instance.</param>
40+
/// <param name="contentTypeKey">The content type key to use.</param>
41+
public static void ContentTypeKey(this SerializationExtensions<HyperionSerializer> config, string contentTypeKey)
42+
{
43+
Guard.AgainstNull(config, nameof(config));
44+
Guard.AgainstNullOrEmpty(contentTypeKey, nameof(contentTypeKey));
45+
var settings = config.GetSettings();
46+
settings.Set("NServiceBus.Hyperion.ContentTypeKey", contentTypeKey);
47+
}
48+
49+
internal static string GetContentTypeKey(this ReadOnlySettings settings)
50+
{
51+
return settings.GetOrDefault<string>("NServiceBus.Hyperion.ContentTypeKey");
52+
}
53+
}
54+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using NServiceBus.Serialization;
5+
using Hyperion;
6+
7+
class HyperionMessageSerializer : IMessageSerializer
8+
{
9+
Serializer serializer;
10+
11+
public HyperionMessageSerializer(string contentType, SerializerOptions options)
12+
{
13+
if (options == null)
14+
{
15+
serializer = new Serializer();
16+
}
17+
else
18+
{
19+
serializer = new Serializer(options);
20+
}
21+
22+
if (contentType == null)
23+
{
24+
ContentType = "hyperion";
25+
}
26+
else
27+
{
28+
ContentType = contentType;
29+
}
30+
}
31+
32+
public void Serialize(object message, Stream stream)
33+
{
34+
var messageType = message.GetType();
35+
if (messageType.Name.EndsWith("__impl"))
36+
{
37+
throw new Exception("Interface based message are not currently supported. Create a class that implements the desired interface.");
38+
}
39+
serializer.Serialize(message, stream);
40+
}
41+
42+
public object[] Deserialize(Stream stream, IList<Type> messageTypes = null)
43+
{
44+
return new [] { serializer.Deserialize(stream) };
45+
}
46+
47+
public string ContentType { get; }
48+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
namespace NServiceBus.Hyperion
2+
{
3+
using System;
4+
using MessageInterfaces;
5+
using Serialization;
6+
using Settings;
7+
8+
/// <summary>
9+
/// Defines the capabilities of the Hyperion serializer
10+
/// </summary>
11+
public class HyperionSerializer : SerializationDefinition
12+
{
13+
/// <summary>
14+
/// <see cref="SerializationDefinition.Configure"/>
15+
/// </summary>
16+
public override Func<IMessageMapper, IMessageSerializer> Configure(ReadOnlySettings settings)
17+
{
18+
return mapper =>
19+
{
20+
var options = settings.GetOptions();
21+
var contentTypeKey = settings.GetContentTypeKey();
22+
return new HyperionMessageSerializer(contentTypeKey, options);
23+
};
24+
}
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project Sdk="Microsoft.NET.Sdk">
3+
<PropertyGroup>
4+
<TargetFramework>net452</TargetFramework>
5+
<WarningLevel>4</WarningLevel>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
8+
<DocumentationFile>$(ProjectDir)bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
9+
</PropertyGroup>
10+
<ItemGroup>
11+
<PackageReference Include="Hyperion" Version="0.9.2" />
12+
<PackageReference Include="NServiceBus" Version="6.3.3" />
13+
<PackageReference Include="PepitaPackage" Version="1.21.4" />
14+
</ItemGroup>
15+
<Target Name="NuGetBuild" AfterTargets="AfterBuild">
16+
<ItemGroup>
17+
<FilesToDelete Include="$(SolutionDir)NuGetBuild\**\*.*" />
18+
</ItemGroup>
19+
<Delete Files="@(FilesToDelete)" />
20+
<Copy SourceFiles="$(OutputPath)NServiceBus.Hyperion.dll" DestinationFolder="$(SolutionDir)NuGetBuild\lib\net452" />
21+
<Copy SourceFiles="$(OutputPath)NServiceBus.Hyperion.pdb" DestinationFolder="$(SolutionDir)NuGetBuild\lib\net452" />
22+
<Copy SourceFiles="$(OutputPath)NServiceBus.Hyperion.xml" DestinationFolder="$(SolutionDir)NuGetBuild\lib\net452" />
23+
<Copy SourceFiles="$(ProjectDir)NServiceBus.Hyperion.nuspec" DestinationFolder="$(SolutionDir)NuGetBuild" />
24+
<PepitaPackage.CreatePackageTask NuGetBuildDirectory="$(SolutionDir)NuGetBuild" MetadataAssembly="$(OutputPath)\NServiceBus.Hyperion.dll" />
25+
</Target>
26+
</Project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3+
<metadata>
4+
<id>NServiceBus.Hyperion</id>
5+
<version>$version$</version>
6+
<title>NServiceBus.Hyperion</title>
7+
<authors>Simon Cropp</authors>
8+
<owners>Simon Cropp</owners>
9+
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
10+
<projectUrl>http://github.com/simoncropp/NServiceBus.Hyperion</projectUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<iconUrl>https://raw.githubusercontent.com/simoncropp/NServiceBus.Hyperion/master/icon.png</iconUrl>
13+
<description>Hyperion (https://github.com/akkadotnet/Hyperion) serializer for NServiceBus.</description>
14+
<language>en-AU</language>
15+
<tags>NServiceBus, Hyperion, Serialization</tags>
16+
<dependencies>
17+
<dependency id="NServiceBus" version="[6.0.0, 7.0.0)" />
18+
<dependency id="Hyperion" version="(,1.0]" />
19+
</dependencies>
20+
</metadata>
21+
</package>

0 commit comments

Comments
 (0)