/// <summary> /// This class manages a string dictionary in a persisted file. /// </summary> /// <param name="FileName">File name of index file.</param> /// <param name="BlobFileName">Name of file in which BLOBs are stored.</param> /// <param name="CollectionName">Collection Name.</param> /// <param name="Provider">Files provider.</param> /// <param name="RetainInMemory">Retain the dictionary in memory.</param> public StringDictionary(string FileName, string BlobFileName, string CollectionName, FilesProvider Provider, bool RetainInMemory) { this.provider = Provider; this.collectionName = CollectionName; this.encoding = this.provider.Encoding; this.timeoutMilliseconds = this.provider.TimeoutMilliseconds; this.genericSerializer = new GenericObjectSerializer(this.provider); this.keyValueSerializer = new KeyValueSerializer(this.provider, this.genericSerializer); this.recordHandler = new StringDictionaryRecords(this.collectionName, this.encoding, (this.provider.BlockSize - ObjectBTreeFile.BlockHeaderSize) / 2 - 4, this.genericSerializer, this.provider); this.dictionaryFile = new ObjectBTreeFile(FileName, this.collectionName, BlobFileName, this.provider.BlockSize, this.provider.BlobBlockSize, this.provider, this.encoding, this.timeoutMilliseconds, #if NETSTANDARD1_5 this.provider.Encrypted, Provider.Debug, this.recordHandler); #else Provider.Debug, this.recordHandler); #endif if (RetainInMemory) { this.inMemory = new Dictionary <string, object>(); } else { this.inMemory = null; } }
protected void Test <T>(Dictionary <string, object> dict, Action <T> assert) { GenericObjectSerializer serializer = new GenericObjectSerializer(); T obj = serializer.Deserialize <T>(dict); assert(obj); }
/// <summary> /// Handles string dictionary entries. /// </summary> /// <param name="CollectionName">Name of current collection.</param> /// <param name="Encoding">Encoding to use for text.</param> /// <param name="GenericSerializer">Generic serializer.</param> /// <param name="Provider">Files database provider.</param> public StringDictionaryRecords(string CollectionName, Encoding Encoding, GenericObjectSerializer GenericSerializer, FilesProvider Provider) { this.collectionName = CollectionName; this.encoding = Encoding; this.genericSerializer = GenericSerializer; this.provider = Provider; }
/// <summary> /// This class manages an index file to a <see cref="ObjectBTreeFile"/>. /// </summary> /// <param name="FileName">File name of index file.</param> /// <param name="ObjectFile">Object file storing actual objects.</param> /// <param name="Provider">Files provider.</param> /// <param name="FieldNames">Field names to build the index on. By default, sort order is ascending. /// If descending sort order is desired, prefix the corresponding field name by a hyphen (minus) sign.</param> internal IndexBTreeFile(string FileName, ObjectBTreeFile ObjectFile, FilesProvider Provider, params string[] FieldNames) { this.objectFile = ObjectFile; this.collectionName = this.objectFile.CollectionName; this.encoding = this.objectFile.Encoding; this.recordHandler = new IndexRecords(this.collectionName, this.encoding, this.objectFile.InlineObjectSizeLimit, FieldNames); this.genericSerializer = new GenericObjectSerializer(this.objectFile.Provider); this.indexFile = new ObjectBTreeFile(FileName, string.Empty, string.Empty, this.objectFile.BlockSize, this.objectFile.BlobBlockSize, Provider, this.encoding, this.objectFile.TimeoutMilliseconds, this.objectFile.Encrypted, this.recordHandler); this.recordHandler.Index = this; }
/// <summary> /// This class manages a string dictionary in a persisted file. /// </summary> /// <param name="CollectionName">Collection Name.</param> /// <param name="Provider">Files provider.</param> /// <param name="RetainInMemory">Retain the dictionary in memory.</param> private StringDictionary(string CollectionName, FilesProvider Provider, bool RetainInMemory) { this.provider = Provider; this.collectionName = CollectionName; this.encoding = this.provider.Encoding; this.timeoutMilliseconds = this.provider.TimeoutMilliseconds; this.genericSerializer = new GenericObjectSerializer(this.provider); this.keyValueSerializer = new KeyValueSerializer(this.provider, this.genericSerializer); this.recordHandler = new StringDictionaryRecords(this.collectionName, this.encoding, this.genericSerializer, this.provider); if (RetainInMemory) { this.inMemory = new Dictionary <string, object>(); } else { this.inMemory = null; } }