public InternalSerializer(GroBufWriter groBufWriter, GroBufReader groBufReader, Type type, bool ignoreCustomSerializer)
 {
     this.groBufWriter           = groBufWriter;
     this.groBufReader           = groBufReader;
     this.type                   = type;
     this.ignoreCustomSerializer = ignoreCustomSerializer;
 }
示例#2
0
        public Serializer(IDataMembersExtractor dataMembersExtractor, IGroBufCustomSerializerCollection customSerializerCollection = null, GroBufOptions options = GroBufOptions.None)
        {
            customSerializerCollection = customSerializerCollection ?? new DefaultGroBufCustomSerializerCollection();
            Func <Type, IGroBufCustomSerializer> factory     = type => new InternalSerializer(writer, reader, type, false);
            Func <Type, IGroBufCustomSerializer> baseFactory = type => new InternalSerializer(writer, reader, type, true);
            var id = Interlocked.Increment(ref serializerId) - 1;

            writer = new GroBufWriter(id, dataMembersExtractor, customSerializerCollection, options, factory, baseFactory);
            reader = new GroBufReader(id, dataMembersExtractor, customSerializerCollection, options, factory, baseFactory);
            if (options.HasFlag(GroBufOptions.WriteEmptyObjects))
            {
                writerWritingEmptyObjects = writer;
            }
            else
            {
                id = Interlocked.Increment(ref serializerId) - 1;
                writerWritingEmptyObjects = new GroBufWriter(id, dataMembersExtractor, customSerializerCollection, options | GroBufOptions.WriteEmptyObjects, factory, baseFactory);
            }
        }