-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
64 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Reflection; | ||
|
||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
using Orleans; | ||
using Orleans.Runtime.Configuration; | ||
using Orleans.Serialization; | ||
using Orleans.Runtime; | ||
|
||
namespace Orleankka.TestKit | ||
{ | ||
using Utility; | ||
|
||
public class SerializationOptions | ||
{ | ||
internal static readonly SerializationOptions Default = new SerializationOptions(false); | ||
|
||
readonly SerializationManager manager; | ||
|
||
public SerializationOptions(bool roundtrip, params Type[] serializers) | ||
{ | ||
Requires.NotNull(serializers, nameof(serializers)); | ||
|
||
if (!roundtrip) | ||
return; | ||
|
||
var configuration = new ClientConfiguration | ||
{ | ||
GatewayProvider = ClientConfiguration.GatewayProviderType.Config, | ||
Gateways = { new IPEndPoint(0, 0) }, | ||
TraceToConsole = false, | ||
DefaultTraceLevel = Severity.Off | ||
}; | ||
|
||
if (serializers.Length > 0) | ||
configuration.SerializationProviders.AddRange(serializers.Select(x => x.GetTypeInfo())); | ||
|
||
var client = new ClientBuilder() | ||
.UseConfiguration(configuration) | ||
.Build(); | ||
|
||
manager = client.ServiceProvider.GetRequiredService<SerializationManager>(); | ||
} | ||
|
||
internal object Roundtrip(object obj) => manager != null | ||
? manager.RoundTripSerializationForTesting(obj) | ||
: obj; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters