public SerializationService Build()
        {
            if (_portableVersion < 0)
            {
                _portableVersion = 0;
            }

            if (_options != null)
            {
                AddConfigDataSerializableFactories(_dataSerializableFactories, _options);
                AddConfigPortableFactories(_portableFactories, _options);
                _classDefinitions = _classDefinitions.Union(_options.ClassDefinitions).ToList();
            }

            var service = new SerializationService(
                _endianness,
                _portableVersion,
                _dataSerializableFactories,
                _portableFactories,
                _classDefinitions,
                _hooks,
                _definitions,
                _checkClassDefErrors,
                _partitioningStrategy,
                _initialOutputBufferSize,
                _loggerFactory);

            if (_options != null)
            {
                var globalSerializer = _options.GlobalSerializer;
                if (globalSerializer.IsConfigured)
                {
                    service.SetGlobalSerializer(globalSerializer.Service, globalSerializer.OverrideClrSerialization);
                }

                foreach (var serializer in _options.Serializers)
                {
                    service.AddConfiguredSerializer(serializer.SerializedType, serializer.Service);
                }
            }

            return(service);
        }
 internal PortableContext(SerializationService serializationService, int version)
 {
     _serializationService = serializationService;
     _version = version;
 }
예제 #3
0
 /// <inheritdoc />
 public void WriteObject(object o)
 {
     SerializationService.WriteObject(this, o);
 }