public MemoryDatabaseBase(byte[] databaseBinary, bool internString = true, IFormatterResolver formatterResolver = null)
        {
            var formatter = new DictionaryFormatter <string, (int, int)>();
            var header    = formatter.Deserialize(databaseBinary, 0, new HeaderFormatterResolver(), out var headerOffset);

            var resolver = formatterResolver ?? MessagePackSerializer.DefaultResolver;

            if (internString)
            {
                resolver = new InternStringResolver(resolver);
            }

            Init(header, headerOffset, databaseBinary, resolver);
        }
Пример #2
0
        public MemoryDatabaseBase(byte[] databaseBinary, bool internString = true, IFormatterResolver formatterResolver = null)
        {
            var reader    = new MessagePackReader(databaseBinary);
            var formatter = new DictionaryFormatter <string, (int, int)>();

            var header   = formatter.Deserialize(ref reader, HeaderFormatterResolver.StandardOptions);
            var resolver = formatterResolver ?? MessagePackSerializer.DefaultOptions.Resolver;

            if (internString)
            {
                resolver = new InternStringResolver(resolver);
            }

            Init(header, databaseBinary.AsMemory((int)reader.Consumed), MessagePackSerializer.DefaultOptions.WithResolver(resolver).WithCompression(MessagePackCompression.Lz4Block));
        }