private Dictionary <TKey, object[]> InitExcel(string filetype)
        {
            string password = "";

            if (filetype.Length > 5)
            {
                password = filetype.Substring(6);
            }

            EXCELSerializer <TKey> excel = new EXCELSerializer <TKey>(_entityType, password, _options.DatabaseName, _options.Location, _keyValueFactory);

            UpdateMethod = new Action <Dictionary <TKey, object[]> >((list) =>
            {
                excel.Serialize(ConvertToProvider(list));
            });

            Dictionary <TKey, object[]> newlist     = new Dictionary <TKey, object[]>(_keyValueFactory.EqualityComparer);
            Dictionary <TKey, object[]> excelresult = excel.Deserialize(newlist);

            return(excelresult);
        }
Esempio n. 2
0
        private Dictionary <TKey, object[]> InitExcel(string filetype)
        {
            string password = "";

            if (filetype.Length > 5)
            {
                password = filetype.Substring(6);
            }

            EXCELSerializer excel = new EXCELSerializer(entityType, password, options.DatabaseName);

            UpdateMethod = new Action <Dictionary <TKey, object[]> >((list) =>
            {
                excel.Serialize(list);
            });

            Dictionary <TKey, object[]> newlist     = new Dictionary <TKey, object[]>(_keyValueFactory.EqualityComparer);
            Dictionary <TKey, object[]> excelresult = excel.Deserialize(newlist);

            GenerateLastAutoPropertyValues(excelresult);
            return(excelresult);
        }
Esempio n. 3
0
        private Dictionary <TKey, object[]> Init()
        {
            filetype = options.Serializer;

            if (filetype.Length >= 5 && filetype.Substring(0, 5) == "excel")
            {
                string password = "";

                if (filetype.Length > 5)
                {
                    password = filetype.Substring(6);
                }

                EXCELSerializer excel = new EXCELSerializer(entityType, password);

                UpdateMethod = new Action <Dictionary <TKey, object[]> >((list) =>
                {
                    excel.Serialize(list);
                });

                Dictionary <TKey, object[]> newlist     = new Dictionary <TKey, object[]>(_keyValueFactory.EqualityComparer);
                Dictionary <TKey, object[]> excelresult = excel.Deserialize(newlist);
                GenerateLastAutoPropertyValues(excelresult);
                return(excelresult);
            }

            if (options.Serializer == "xml")
            {
                serializer = new XMLSerializer(entityType);
            }
            else if (options.Serializer == "bson")
            {
                serializer = new BSONSerializer(entityType);
            }
            else if (options.Serializer == "csv")
            {
                serializer = new CSVSerializer(entityType);
            }
            else
            {
                serializer = new JSONSerializer(entityType);
            }

            string fmgr = options.FileManager;

            if (fmgr.Length >= 9 && fmgr.Substring(0, 9) == "encrypted")
            {
                string password = "";

                if (fmgr.Length > 9)
                {
                    password = fmgr.Substring(10);
                }

                fileManager = new EncryptedFileManager(entityType, filetype, password, options.DatabaseName);
            }
            else if (fmgr == "private")
            {
                fileManager = new PrivateFileManager(entityType, filetype, options.DatabaseName);
            }
            else
            {
                fileManager = new DefaultFileManager(entityType, filetype, options.DatabaseName);
            }

            UpdateMethod = new Action <Dictionary <TKey, object[]> >((list) =>
            {
                string cnt = serializer.Serialize(list);
                fileManager.SaveContent(cnt);
            });

            string content = fileManager.LoadContent();
            Dictionary <TKey, object[]> newList = new Dictionary <TKey, object[]>(_keyValueFactory.EqualityComparer);
            Dictionary <TKey, object[]> result  = serializer.Deserialize(content, newList);

            GenerateLastAutoPropertyValues(result);
            return(result);
        }