Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HyperionSerializer"/> class.
        /// </summary>
        /// <param name="system">The actor system to associate with this serializer.</param>
        /// <param name="settings">Serializer settings.</param>
        public HyperionSerializer(ExtendedActorSystem system, HyperionSerializerSettings settings)
            : base(system)
        {
            Settings = settings;
            var akkaSurrogate =
                Surrogate
                .Create <ISurrogated, ISurrogate>(
                    from => from.ToSurrogate(system),
                    to => to.FromSurrogate(system));

            var provider = CreateKnownTypesProvider(system, settings.KnownTypesProvider);

            if (system != null)
            {
                var settingsSetup = system.Settings.Setup.Get <HyperionSerializerSetup>()
                                    .GetOrElse(HyperionSerializerSetup.Empty);

                settingsSetup.ApplySettings(Settings);
            }

            _serializer =
                new HySerializer(new SerializerOptions(
                                     versionTolerance: settings.VersionTolerance,
                                     preserveObjectReferences: settings.PreserveObjectReferences,
                                     surrogates: new[] { akkaSurrogate },
                                     serializerFactories: null,
                                     knownTypes: provider.GetKnownTypes(),
                                     ignoreISerializable: true,
                                     packageNameOverrides: settings.PackageNameOverrides));
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HyperionSerializer"/> class.
        /// </summary>
        /// <param name="system">The actor system to associate with this serializer.</param>
        /// <param name="settings">Serializer settings.</param>
        public HyperionSerializer(ExtendedActorSystem system, HyperionSerializerSettings settings)
            : base(system)
        {
            this.Settings = settings;
            var akkaSurrogate =
                Surrogate
                .Create <ISurrogated, ISurrogate>(
                    from => from.ToSurrogate(system),
                    to => to.FromSurrogate(system));

            var provider = CreateKnownTypesProvider(system, settings.KnownTypesProvider);

            _serializer =
                new Hyperion.Serializer(new SerializerOptions(
                                            preserveObjectReferences: settings.PreserveObjectReferences,
                                            versionTolerance: settings.VersionTolerance,
                                            surrogates: new[] { akkaSurrogate },
                                            knownTypes: provider.GetKnownTypes()));
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HyperionSerializer"/> class.
 /// </summary>
 /// <param name="system">The actor system to associate with this serializer.</param>
 /// <param name="config">Configuration passed from related HOCON config path.</param>
 public HyperionSerializer(ExtendedActorSystem system, Config config)
     : this(system, HyperionSerializerSettings.Create(config))
 {
 }