예제 #1
0
        public void Initialize(Logger logger)
        {
            var surogates = new[]
            {
                Surrogate.Create <ActorPath, ActorPathSurrogate>(ActorPathSurrogate.From, x => x.Original()),
                Surrogate.Create <StreamPath, StreamPathSurrogate>(StreamPathSurrogate.From, x => x.Original()),
                Surrogate.Create <ActorRef, ActorRefSurrogate>(ActorRefSurrogate.From, x => x.Original(this)),
                Surrogate.Create <StreamRef, StreamRefSurrogate>(StreamRefSurrogate.From, x => x.Original(this)),
                Surrogate.Create <ClientRef, ClientRefSurrogate>(ClientRefSurrogate.From, x => x.Original(this)),
            };

            var options = new SerializerOptions(
                versionTolerance: true,
                preserveObjectReferences: true,
                surrogates: surogates);

            serializer = new Hyperion.Serializer(options);

            options = new SerializerOptions(
                versionTolerance: false,
                preserveObjectReferences: true,
                surrogates: surogates);

            copier = new Hyperion.Serializer(options);
        }
예제 #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)
        {
            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));
        }
예제 #3
0
        /// <summary>Constructor</summary>
        public HyperionMessageFormatter()
        {
            var options = new SerializerOptions(versionTolerance: false, preserveObjectReferences: true);

            _serializer = new Hyperion.Serializer(options);
            var copyOptions = new SerializerOptions(versionTolerance: false, preserveObjectReferences: true);

            _copier = new Hyperion.Serializer(copyOptions);
        }
예제 #4
0
        /// <summary>Constructor</summary>
        public HyperionMessageFormatter(SerializerOptions options)
        {
            if (null == options)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.options);
            }

            _serializer = new Hyperion.Serializer(options);
            var copyOptions = options.Clone(false);

            _copier = new Hyperion.Serializer(copyOptions);
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WireSerializer"/> class.
        /// </summary>
        /// <param name="system">The actor system to associate with this serializer.</param>
        public WireSerializer(ExtendedActorSystem system) : base(system)
        {
            var akkaSurrogate =
                Surrogate
                .Create <ISurrogated, ISurrogate>(
                    from => from.ToSurrogate(system),
                    to => to.FromSurrogate(system));

            _serializer =
                new Hyperion.Serializer(new SerializerOptions(
                                            preserveObjectReferences: true,
                                            versionTolerance: true,
                                            surrogates: new[]
            {
                akkaSurrogate
            }));
        }
예제 #6
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()));
        }
        public HyperionSerializer(ExtendedActorSystem system) : base(system)
        {
            var serializerOptions = new SerializerOptions(false, true);

            _serializer = new Hyperion.Serializer(serializerOptions);
        }