From 7dd1989fb99533b828717cd22b5ce2fe977e8d71 Mon Sep 17 00:00:00 2001 From: Morris Janatzek Date: Fri, 23 Aug 2019 19:41:14 +0200 Subject: [PATCH] added custom location for data removed redundant key field from serializer --- Example/Data/Context.cs | 8 ++--- .../FileContextDbContextOptionsExtensions.cs | 8 ++--- FileContextCore/FileContextCore.csproj | 4 +-- .../FileManager/DefaultFileManager.cs | 11 +++++-- .../FileManager/EncryptedFileManager.cs | 17 +++++----- .../FileManager/PrivateFileManager.cs | 11 +++++-- .../Internal/FileContextOptionsExtension.cs | 13 ++++++-- FileContextCore/Serializer/BSONSerializer.cs | 14 ++++---- FileContextCore/Serializer/CSVSerializer.cs | 15 +++++---- FileContextCore/Serializer/EXCELSerializer.cs | 32 +++++++++++-------- FileContextCore/Serializer/JSONSerializer.cs | 16 ++++++---- .../Serializer/SerializerHelper.cs | 13 ++++++++ FileContextCore/Serializer/XMLSerializer.cs | 11 ++++--- .../Storage/Internal/FileContextTable.cs | 17 +++++----- 14 files changed, 118 insertions(+), 72 deletions(-) diff --git a/Example/Data/Context.cs b/Example/Data/Context.cs index 685c653..3ea98bf 100644 --- a/Example/Data/Context.cs +++ b/Example/Data/Context.cs @@ -21,9 +21,9 @@ public class Context : DbContext protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { //Default: JSON-Serialize - //optionsBuilder.UseFileContext(); + optionsBuilder.UseFileContext(); - optionsBuilder.UseFileContext("bson"); + //optionsBuilder.UseFileContext("bson"); //JSON-Serialize + simple Encryption //optionsBuilder.UseFileContext("json", "encrypted"); @@ -33,10 +33,10 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) //optionsBuilder.UseFileContext("xml", "private"); //CSV - //optionsBuilder.UseFileContext("csv"); + //optionsBuilder.UseFileContext("csv", location: @"C:\Users\mjanatzek\Documents\Projects\t"); //Excel - //optionsBuilder.UseFileContext("excel"); + //optionsBuilder.UseFileContext("excel", databasename: "test", location: @"C:\Users\mjanatzek\Documents\Projects\t"); } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/FileContextCore/Extensions/FileContextDbContextOptionsExtensions.cs b/FileContextCore/Extensions/FileContextDbContextOptionsExtensions.cs index 9e50494..4e10a9b 100644 --- a/FileContextCore/Extensions/FileContextDbContextOptionsExtensions.cs +++ b/FileContextCore/Extensions/FileContextDbContextOptionsExtensions.cs @@ -32,10 +32,10 @@ public static class FileContextDbContextOptionsExtensions /// The options builder so that further configuration can be chained. public static DbContextOptionsBuilder UseFileContext( [NotNull] this DbContextOptionsBuilder optionsBuilder, - string serializer = "json", string filemanager = "default", string databasename = "") + string serializer = "json", string filemanager = "default", string databasename = "", string location = "") where TContext : DbContext => (DbContextOptionsBuilder)UseFileContext( - (DbContextOptionsBuilder)optionsBuilder, serializer, filemanager, databasename); + (DbContextOptionsBuilder)optionsBuilder, serializer, filemanager, databasename, location); /// /// Configures the context to use FileContext. @@ -49,14 +49,14 @@ public static DbContextOptionsBuilder UseFileContext( /// The selection the of the file-manager to encrypt the files for example. /// The options builder so that further configuration can be chained. public static DbContextOptionsBuilder UseFileContext( - [NotNull] this DbContextOptionsBuilder optionsBuilder, string serializer = "json", string filemanager = "default", string databasename = "") + [NotNull] this DbContextOptionsBuilder optionsBuilder, string serializer = "json", string filemanager = "default", string databasename = "", string location = "") { Check.NotNull(optionsBuilder, nameof(optionsBuilder)); FileContextOptionsExtension extension = optionsBuilder.Options.FindExtension() ?? new FileContextOptionsExtension(); - extension = extension.WithSerializerAndFileManager(serializer, filemanager, databasename); + extension = extension.WithSerializerAndFileManager(serializer, filemanager, databasename, location); ((IDbContextOptionsBuilderInfrastructure)optionsBuilder).AddOrUpdateExtension(extension); diff --git a/FileContextCore/FileContextCore.csproj b/FileContextCore/FileContextCore.csproj index ffc706c..cef1eed 100644 --- a/FileContextCore/FileContextCore.csproj +++ b/FileContextCore/FileContextCore.csproj @@ -5,7 +5,7 @@ true key.snk true - 2.2.6 + 3.0.0 morrisjdev morrisjdev File provider for Entity Framework Core (to be used for development purposes) @@ -19,7 +19,7 @@ https://github.com/morrisjdev/FileContextCore en-US false - 2.2.6.0 + 3.0.0.0 diff --git a/FileContextCore/FileManager/DefaultFileManager.cs b/FileContextCore/FileManager/DefaultFileManager.cs index 52fe668..eeb0d92 100644 --- a/FileContextCore/FileManager/DefaultFileManager.cs +++ b/FileContextCore/FileManager/DefaultFileManager.cs @@ -12,19 +12,24 @@ class DefaultFileManager : IFileManager IEntityType type; private readonly string filetype; private readonly string databasename; + private readonly string _location; - public DefaultFileManager(IEntityType _type, string _filetype, string _databasename) + public DefaultFileManager(IEntityType _type, string _filetype, string _databasename, string location) { type = _type; filetype = _filetype; databasename = _databasename; + _location = location; } public string GetFileName() { string name = type.Relational().TableName.GetValidFileName(); - string path = Path.Combine(AppContext.BaseDirectory, "appdata", databasename); - + + string path = string.IsNullOrEmpty(_location) + ? Path.Combine(AppContext.BaseDirectory, "appdata", databasename) + : _location; + Directory.CreateDirectory(path); return Path.Combine(path, name + "." + filetype); diff --git a/FileContextCore/FileManager/EncryptedFileManager.cs b/FileContextCore/FileManager/EncryptedFileManager.cs index 6e61a67..98f4998 100644 --- a/FileContextCore/FileManager/EncryptedFileManager.cs +++ b/FileContextCore/FileManager/EncryptedFileManager.cs @@ -15,27 +15,26 @@ class EncryptedFileManager : IFileManager private readonly string filetype; private readonly string key; private readonly string databasename; + private readonly string _location; - public EncryptedFileManager(IEntityType _type, string _filetype, string _key, string _databasename) + public EncryptedFileManager(IEntityType _type, string _filetype, string _key, string _databasename, string _location) { type = _type; filetype = _filetype; key = _key; databasename = _databasename; + this._location = _location; } public string GetFileName() { - string name = type.Relational().TableName; + string name = type.Relational().TableName.GetValidFileName(); - foreach(char c in Path.GetInvalidFileNameChars()) - { - name = name.Replace(c, '_'); - } - - string path = Path.Combine(AppContext.BaseDirectory, "appdata", databasename); + string path = string.IsNullOrEmpty(_location) + ? Path.Combine(AppContext.BaseDirectory, "appdata", databasename) + : _location; - Directory.CreateDirectory(path); + Directory.CreateDirectory(path); return Path.Combine(path, name + "." + filetype + ".crypted"); } diff --git a/FileContextCore/FileManager/PrivateFileManager.cs b/FileContextCore/FileManager/PrivateFileManager.cs index b7343c8..15ea229 100644 --- a/FileContextCore/FileManager/PrivateFileManager.cs +++ b/FileContextCore/FileManager/PrivateFileManager.cs @@ -14,20 +14,25 @@ class PrivateFileManager : IFileManager IEntityType type; private readonly string filetype; private readonly string databasename; + private readonly string _location; - public PrivateFileManager(IEntityType _type, string _filetype, string _databasename) + public PrivateFileManager(IEntityType _type, string _filetype, string _databasename, string _location) { type = _type; filetype = _filetype; databasename = _databasename; + this._location = _location; } public string GetFileName() { string name = type.Relational().TableName.GetValidFileName(); - string path = Path.Combine(AppContext.BaseDirectory, "appdata", databasename); - Directory.CreateDirectory(path); + string path = string.IsNullOrEmpty(_location) + ? Path.Combine(AppContext.BaseDirectory, "appdata", databasename) + : _location; + + Directory.CreateDirectory(path); return Path.Combine(path, name + ".private." + filetype); } diff --git a/FileContextCore/Infrastructure/Internal/FileContextOptionsExtension.cs b/FileContextCore/Infrastructure/Internal/FileContextOptionsExtension.cs index 2445164..d301b35 100644 --- a/FileContextCore/Infrastructure/Internal/FileContextOptionsExtension.cs +++ b/FileContextCore/Infrastructure/Internal/FileContextOptionsExtension.cs @@ -18,6 +18,7 @@ class FileContextOptionsExtension : IDbContextOptionsExtension { private string _serializer = "json"; private string _filemanager = "default"; + private string _location = ""; private string _databasename = ""; private string _logFragment; @@ -38,6 +39,7 @@ protected FileContextOptionsExtension([NotNull] FileContextOptionsExtension copy { _serializer = copyFrom._serializer; _filemanager = copyFrom._filemanager; + _location = copyFrom._location; } /// @@ -56,17 +58,20 @@ protected FileContextOptionsExtension([NotNull] FileContextOptionsExtension copy public virtual string DatabaseName => _databasename; + public virtual string Location => _location; + /// /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public virtual FileContextOptionsExtension WithSerializerAndFileManager(string serializer, string filemanager, string databasename) + public virtual FileContextOptionsExtension WithSerializerAndFileManager(string serializer, string filemanager, string databasename, string location) { FileContextOptionsExtension clone = Clone(); clone._serializer = serializer; clone._filemanager = filemanager; clone._databasename = databasename; + clone._location = location; return clone; } @@ -110,7 +115,11 @@ public virtual string LogFragment { StringBuilder builder = new StringBuilder(); - builder.Append("serializer=").Append(_serializer).Append(";filemanager=").Append(_filemanager).Append(";databasename=").Append(_databasename).Append(' '); + builder + .Append("serializer=").Append(_serializer) + .Append(";filemanager=").Append(_filemanager) + .Append(";databasename=").Append(_databasename) + .Append(";location=").Append(_location).Append(' '); _logFragment = builder.ToString(); } diff --git a/FileContextCore/Serializer/BSONSerializer.cs b/FileContextCore/Serializer/BSONSerializer.cs index 8f89a83..772f79a 100644 --- a/FileContextCore/Serializer/BSONSerializer.cs +++ b/FileContextCore/Serializer/BSONSerializer.cs @@ -7,18 +7,21 @@ using System.Linq; using System.Text; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; namespace FileContextCore.Serializer { - class BSONSerializer : ISerializer + class BSONSerializer : ISerializer { private IEntityType entityType; + private readonly IPrincipalKeyValueFactory _keyValueFactory; private string[] propertyKeys; private readonly Type[] typeList; - public BSONSerializer(IEntityType _entityType) + public BSONSerializer(IEntityType _entityType, IPrincipalKeyValueFactory _keyValueFactory) { entityType = _entityType; + this._keyValueFactory = _keyValueFactory; propertyKeys = entityType.GetProperties().Select(p => p.Relational().ColumnName).ToArray(); typeList = entityType.GetProperties().Select(p => p.GetValueConverter()?.ProviderClrType ?? p.ClrType).ToArray(); } @@ -52,7 +55,9 @@ private void DeserializeValues(JObject array, Dictionary n { JObject json = (JObject)current.Value; - TKey key = (TKey)json.Value("__Key__").Deserialize(typeof(TKey)); + TKey key = SerializerHelper.GetKey(_keyValueFactory, entityType, + propertyName => json.Value(propertyName)); + List value = new List(); for (int i = 0; i < propertyKeys.Length; i++) @@ -79,9 +84,6 @@ public string Serialize(Dictionary list) { writer.WriteStartObject(); - writer.WritePropertyName("__Key__"); - writer.WriteValue(val.Key.Serialize()); - for (int i = 0; i < propertyKeys.Length; i++) { writer.WritePropertyName(propertyKeys[i]); diff --git a/FileContextCore/Serializer/CSVSerializer.cs b/FileContextCore/Serializer/CSVSerializer.cs index 5e39b9b..7b39ad8 100644 --- a/FileContextCore/Serializer/CSVSerializer.cs +++ b/FileContextCore/Serializer/CSVSerializer.cs @@ -6,18 +6,21 @@ using System.Linq; using System.Text; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; namespace FileContextCore.Serializer { - class CSVSerializer : ISerializer + class CSVSerializer : ISerializer { private IEntityType entityType; + private readonly IPrincipalKeyValueFactory _keyValueFactory; private string[] propertyKeys; private readonly Type[] typeList; - public CSVSerializer(IEntityType _entityType) + public CSVSerializer(IEntityType _entityType, IPrincipalKeyValueFactory _keyValueFactory) { entityType = _entityType; + this._keyValueFactory = _keyValueFactory; propertyKeys = entityType.GetProperties().Select(p => p.Relational().ColumnName).ToArray(); typeList = entityType.GetProperties().Select(p => p.GetValueConverter()?.ProviderClrType ?? p.ClrType).ToArray(); } @@ -37,7 +40,6 @@ public Dictionary Deserialize(string list, Dictionary value = new List(); for (int i = 0; i < propertyKeys.Length; i++) @@ -46,6 +48,9 @@ public Dictionary Deserialize(string list, Dictionary(_keyValueFactory, entityType, + propertyName => reader.GetField(propertyName)); + newList.Add(key, value.ToArray()); } @@ -57,8 +62,6 @@ public string Serialize(Dictionary list) StringWriter sw = new StringWriter(); CsvWriter writer = new CsvWriter(sw); - writer.WriteField("Key"); - for (int i = 0; i < propertyKeys.Length; i++) { writer.WriteField(propertyKeys[i]); @@ -68,8 +71,6 @@ public string Serialize(Dictionary list) foreach (KeyValuePair val in list) { - writer.WriteField(val.Key.Serialize()); - for (int i = 0; i < propertyKeys.Length; i++) { writer.WriteField(val.Value[i].Serialize()); diff --git a/FileContextCore/Serializer/EXCELSerializer.cs b/FileContextCore/Serializer/EXCELSerializer.cs index 7aecb14..3ab49fd 100644 --- a/FileContextCore/Serializer/EXCELSerializer.cs +++ b/FileContextCore/Serializer/EXCELSerializer.cs @@ -6,16 +6,20 @@ using System.Linq; using System.Text; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; +using Microsoft.EntityFrameworkCore.Internal; namespace FileContextCore.Serializer { - class EXCELSerializer + class EXCELSerializer { private IEntityType entityType; private string[] propertyKeys; private readonly Type[] typeList; private readonly string password; private readonly string databaseName; + private readonly string _location; + private readonly IPrincipalKeyValueFactory _keyValueFactory; private static Dictionary packages = new Dictionary(); private ExcelPackage package; @@ -24,23 +28,27 @@ class EXCELSerializer FileInfo GetFilePath() { - string folder = Path.Combine(AppContext.BaseDirectory, "appdata", databaseName); + string folder = string.IsNullOrEmpty(_location) + ? Path.Combine(AppContext.BaseDirectory, "appdata") + : _location; if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } - return new FileInfo(Path.Combine(folder, "data.xlsx")); + return new FileInfo(Path.Combine(folder, $"{databaseName}.xlsx")); } - public EXCELSerializer(IEntityType _entityType, string _password, string databaseName) + public EXCELSerializer(IEntityType _entityType, string _password, string databaseName, string location, IPrincipalKeyValueFactory _keyValueFactory) { entityType = _entityType; propertyKeys = entityType.GetProperties().Select(p => p.Relational().ColumnName).ToArray(); typeList = entityType.GetProperties().Select(p => p.GetValueConverter()?.ProviderClrType ?? p.ClrType).ToArray(); password = _password; this.databaseName = databaseName; + _location = location; + this._keyValueFactory = _keyValueFactory; if (!packages.ContainsKey(databaseName)) { @@ -68,14 +76,12 @@ public EXCELSerializer(IEntityType _entityType, string _password, string databas if (worksheet == null) { worksheet = package.Workbook.Worksheets.Add(name); - - worksheet.Cells[1, 1].Value = "Key"; worksheet.Column(1).AutoFit(); for (int i = 0; i < propertyKeys.Length; i++) { - worksheet.Cells[1, i + 2].Value = propertyKeys[i]; - worksheet.Column(i + 2).AutoFit(); + worksheet.Cells[1, i + 1].Value = propertyKeys[i]; + worksheet.Column(i + 1).AutoFit(); } worksheet.View.FreezePanes(2, 1); @@ -95,15 +101,17 @@ public Dictionary Deserialize(Dictionary n { for (int y = 2; y < worksheet.Dimension.Rows; y++) { - TKey key = (TKey)worksheet.Cells[y, 1].GetValue().Deserialize(typeof(TKey)); List value = new List(); for (int x = 0; x < propertyKeys.Length; x++) { - object val = worksheet.Cells[y, x + 2].GetValue().Deserialize(typeList[x]); + object val = worksheet.Cells[y, x + 1].GetValue().Deserialize(typeList[x]); value.Add(val); } + TKey key = SerializerHelper.GetKey(_keyValueFactory, entityType, propertyName => + worksheet.Cells[y, propertyKeys.IndexOf(propertyName) + 1].GetValue()); + newList.Add(key, value.ToArray()); } @@ -137,11 +145,9 @@ private void FillRows(Dictionary list) foreach (KeyValuePair val in list) { - worksheet.SetValue(y, 1, val.Key.Serialize()); - for (int x = 0; x < propertyKeys.Length; x++) { - worksheet.SetValue(y, x + 2, val.Value[x].Serialize()); + worksheet.SetValue(y, x + 1, val.Value[x].Serialize()); } y++; diff --git a/FileContextCore/Serializer/JSONSerializer.cs b/FileContextCore/Serializer/JSONSerializer.cs index 98b8403..45a89b1 100644 --- a/FileContextCore/Serializer/JSONSerializer.cs +++ b/FileContextCore/Serializer/JSONSerializer.cs @@ -4,18 +4,21 @@ using System.Collections.Generic; using System.Linq; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; namespace FileContextCore.Serializer { - class JSONSerializer : ISerializer + class JSONSerializer : ISerializer { private IEntityType entityType; + private readonly IPrincipalKeyValueFactory _keyValueFactory; private string[] propertyKeys; private readonly Type[] typeList; - public JSONSerializer(IEntityType _entityType) + public JSONSerializer(IEntityType _entityType, IPrincipalKeyValueFactory _keyValueFactory) { entityType = _entityType; + this._keyValueFactory = _keyValueFactory; propertyKeys = entityType.GetProperties().Select(p => p.Relational().ColumnName).ToArray(); typeList = entityType.GetProperties().Select(p => p.GetValueConverter()?.ProviderClrType ?? p.ClrType).ToArray(); } @@ -28,7 +31,6 @@ public Dictionary Deserialize(string list, Dictionary("__Key__").Deserialize(typeof(TKey)); List value = new List(); for (int i = 0; i < propertyKeys.Length; i++) @@ -37,6 +39,9 @@ public Dictionary Deserialize(string list, Dictionary(_keyValueFactory, entityType, + propertyName => json.Value(propertyName)); + newList.Add(key, value.ToArray()); } } @@ -50,10 +55,7 @@ public string Serialize(Dictionary list) foreach(KeyValuePair val in list) { - JObject json = new JObject - { - new JProperty("__Key__", val.Key.Serialize()) - }; + JObject json = new JObject(); for (int i = 0; i < propertyKeys.Length; i++) { diff --git a/FileContextCore/Serializer/SerializerHelper.cs b/FileContextCore/Serializer/SerializerHelper.cs index 0c49717..f2ef635 100644 --- a/FileContextCore/Serializer/SerializerHelper.cs +++ b/FileContextCore/Serializer/SerializerHelper.cs @@ -1,7 +1,11 @@ using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; using System.Text; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; +using Microsoft.EntityFrameworkCore.Metadata; namespace FileContextCore.Serializer { @@ -60,5 +64,14 @@ public static string Serialize(this object input) return ""; } + + public static TKey GetKey(IPrincipalKeyValueFactory keyValueFactory, IEntityType entityType, Func valueSelector) + { + return (TKey)keyValueFactory.CreateFromKeyValues( + entityType.FindPrimaryKey().Properties + .Select(p => + valueSelector(p.Relational().ColumnName) + .Deserialize(p.GetValueConverter()?.ProviderClrType ?? p.ClrType)).ToArray()); + } } } diff --git a/FileContextCore/Serializer/XMLSerializer.cs b/FileContextCore/Serializer/XMLSerializer.cs index c62b222..42f0f97 100644 --- a/FileContextCore/Serializer/XMLSerializer.cs +++ b/FileContextCore/Serializer/XMLSerializer.cs @@ -8,18 +8,21 @@ using System.Xml.Linq; using System.Xml.Serialization; using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; namespace FileContextCore.Serializer { - class XMLSerializer : ISerializer + class XMLSerializer : ISerializer { private IEntityType entityType; + private readonly IPrincipalKeyValueFactory _keyValueFactory; private string[] propertyKeys; private readonly Type[] typeList; - public XMLSerializer(IEntityType _entityType) + public XMLSerializer(IEntityType _entityType, IPrincipalKeyValueFactory _keyValueFactory) { entityType = _entityType; + this._keyValueFactory = _keyValueFactory; propertyKeys = entityType.GetProperties().Select(p => p.Relational().ColumnName).ToArray(); typeList = entityType.GetProperties().Select(p => p.GetValueConverter()?.ProviderClrType ?? p.ClrType).ToArray(); } @@ -35,7 +38,6 @@ public Dictionary Deserialize(string list, Dictionary attr.Name == "Key")?.Value.Deserialize(typeof(TKey)); Dictionary values = current.Nodes().Select(x => (XElement)x).ToDictionary(x => x.Name.LocalName, x => x.Value); List value = new List(); @@ -45,6 +47,8 @@ public Dictionary Deserialize(string list, Dictionary(_keyValueFactory, entityType, propertyName => values[propertyName]); + newList.Add(key, value.ToArray()); current = (XElement)current.NextNode; @@ -82,7 +86,6 @@ private void WriteList(XmlWriter writer, string name, Dictionary val in list) { writer.WriteStartElement(name); - writer.WriteAttributeString("Key", val.Key.Serialize()); for (int i = 0; i < propertyKeys.Length; i++) { diff --git a/FileContextCore/Storage/Internal/FileContextTable.cs b/FileContextCore/Storage/Internal/FileContextTable.cs index 6bdd6cd..8e4341f 100644 --- a/FileContextCore/Storage/Internal/FileContextTable.cs +++ b/FileContextCore/Storage/Internal/FileContextTable.cs @@ -17,6 +17,7 @@ using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Update; +using OfficeOpenXml.FormulaParsing.Excel.Functions.Text; namespace FileContextCore.Storage.Internal { @@ -182,7 +183,7 @@ private Dictionary InitExcel(string filetype) password = filetype.Substring(6); } - EXCELSerializer excel = new EXCELSerializer(entityType, password, options.DatabaseName); + EXCELSerializer excel = new EXCELSerializer(entityType, password, options.DatabaseName, options.Location, _keyValueFactory); UpdateMethod = new Action>((list) => { @@ -199,19 +200,19 @@ private void InitSerializer() { if (options.Serializer == "xml") { - serializer = new XMLSerializer(entityType); + serializer = new XMLSerializer(entityType, _keyValueFactory); } else if (options.Serializer == "bson") { - serializer = new BSONSerializer(entityType); + serializer = new BSONSerializer(entityType, _keyValueFactory); } else if (options.Serializer == "csv") { - serializer = new CSVSerializer(entityType); + serializer = new CSVSerializer(entityType, _keyValueFactory); } else { - serializer = new JSONSerializer(entityType); + serializer = new JSONSerializer(entityType, _keyValueFactory); } } @@ -228,15 +229,15 @@ private void InitFileManager() password = fmgr.Substring(10); } - fileManager = new EncryptedFileManager(entityType, filetype, password, options.DatabaseName); + fileManager = new EncryptedFileManager(entityType, filetype, password, options.DatabaseName, options.Location); } else if (fmgr == "private") { - fileManager = new PrivateFileManager(entityType, filetype, options.DatabaseName); + fileManager = new PrivateFileManager(entityType, filetype, options.DatabaseName, options.Location); } else { - fileManager = new DefaultFileManager(entityType, filetype, options.DatabaseName); + fileManager = new DefaultFileManager(entityType, filetype, options.DatabaseName, options.Location); } }