Example #1
0
        private IEnumerable <FreeDocument> GetEntities2(
            string tableName, int mount = -1, int skip = 0)
        {
            TableInfo table = null;

            LastFileName = tableName;
            List <string> fileNames = new List <string>();

            if (tableName == openfile && MainDescription.IsUIForm)
            {
                var ofd2 = new OpenFileDialog();
                ofd2.DefaultExt  = "*";
                ofd2.Filter      = FileConnector.GetDataFilter();
                ofd2.Multiselect = true;
                if (ofd2.ShowDialog() == true)
                {
                    fileNames.AddRange(ofd2.FileNames);
                }
            }
            else
            {
                table = TableNames.Collection.FirstOrDefault(d => d.Name == tableName);
                if (table != null)
                {
                    if ((File.Exists(table.Description) == false))
                    {
                        CurrentTables.Remove(table);
                        TableNames.InformPropertyChanged("Collection");
                        return(new List <FreeDocument>());
                    }
                    fileNames.Add(table.Description);
                }
            }

            if (fileNames.Count() == 1)
            {
                var filename = fileNames.FirstOrDefault();
                LastFileName = Path.GetFileName(filename);
                table        = AddTable(LastFileName, filename);
            }



            return(fileNames.SelectMany(d =>
            {
                var connector = FileConnector.SmartGetExport(d);
                var tableConnector2 = connector as FileConnectorTable;
                if (tableConnector2 != null)
                {
                    tableConnector2.EncodingType = this.EncodingType;
                }
                if (mount > 0)
                {
                    return connector.ReadFile().Skip(skip).Take(mount);
                }

                return connector.ReadFile().Skip(skip);
            }));
        }
Example #2
0
        public virtual void ReadConfig(string path = null)
        {
            if (path == null)
            {
                path = SavePath;
            }
            IFileConnector json = FileConnector.SmartGetExport(path);

            json.FileName = path;
            IDictionarySerializable da = json.ReadFile().FirstOrDefault();

            DictDeserialize(da.DictSerialize());
        }
Example #3
0
        public virtual void SaveConfig(string path = null)
        {
            if (path == null)
            {
                path = SavePath;
            }
            IFileConnector json = FileConnector.SmartGetExport(path);

            var Datas = new List <IFreeDocument> {
                DictSerialize()
            };

            json.WriteAll(Datas);
        }