public void Read(CremaDataSet dataSet) { using (var reader = new SpreadsheetReader(this.Path)) { reader.Read(dataSet); } }
private void ReadTables(CremaDataSet dataSet, IDataBase dataBase, string filename, string itemNames) { var sheetNames = SpreadsheetReader.ReadSheetNames(filename); var tableInfos = dataBase.Dispatcher.Invoke(() => { var query = from table in dataBase.TableContext.Tables let tableName2 = SpreadsheetUtility.Ellipsis(table.Name) join sheetName in sheetNames on tableName2 equals sheetName where table.Name.GlobMany(itemNames) || table.Path.GlobMany(itemNames) orderby table.Name select table.TableInfo; return(query.ToArray()); }); var typeInfos = dataBase.Dispatcher.Invoke(() => { var query = from table in dataBase.TableContext.Tables let tableName2 = SpreadsheetUtility.Ellipsis(table.Name) join sheetName in sheetNames on tableName2 equals sheetName where table.Name.GlobMany(itemNames) || table.Path.GlobMany(itemNames) from column in table.TableInfo.Columns where CremaDataTypeUtility.IsBaseType(column.DataType) == false let type = dataBase.TypeContext[column.DataType] as IType where type != null select type.TypeInfo; return(query.Distinct().ToArray()); }); foreach (var item in typeInfos) { dataSet.Types.Add(item); } foreach (var item in tableInfos) { if (item.TemplatedParent != string.Empty) { continue; } if (item.ParentName == string.Empty) { dataSet.Tables.Add(item); } else { dataSet.Tables[item.ParentName].Childs.Add(item); } } foreach (var item in tableInfos) { if (item.TemplatedParent != string.Empty && item.ParentName == string.Empty) { var dataTable = dataSet.Tables[item.TemplatedParent]; dataTable.Inherit(item.TableName); } } var progress = new ConsoleProgress(this.Out) { Style = ConsoleProgressStyle.None }; using (var reader = new SpreadsheetReader(filename)) { reader.Read(dataSet, progress); } }
private static void LoadDictionary() { TextAsset textAsset = Resources.Load <TextAsset>(resourcesPath); if (textAsset != null) { List <List <string> > csv = SpreadsheetReader.Read(textAsset.text, ',', true); int colnCount = csv.Count; int lineCount = csv[0].Count; int langCount = colnCount - 1; int indexOfKeys = csv[0].IndexOf("keys"); if (indexOfKeys < 0) { Debug.LogError("LanguageManager: invalid CSV format. Couldn't find \"keys\" column."); Debug.Break(); } else { dictionary.Clear(); for (int l = 1; l < colnCount; l++) { string langName = csv[l][indexOfKeys]; loadedLanguages.Add(langName.Substring(0, 2)); } for (int x = 0; x < lineCount; x++) { string key = csv[0][x]; if (!dictionary.ContainsKey(key)) { if (!string.IsNullOrEmpty(key) && !key.StartsWith("//")) { string[] lnTranslation = new string[langCount]; for (int l = 0; l < langCount; l++) { lnTranslation[l] = csv[l + 1][x]; } dictionary.Add(key, lnTranslation); } } } string currSysLang = "pt"; if (!loadedLanguages.Contains(currSysLang.Substring(0, 2))) { currSysLang = loadedLanguages[0]; } currentLanguage = currSysLang; currentLanguageIndex = loadedLanguages.IndexOf(currentLanguage); ready = true; onLanguageChange.Invoke(); } } else { Debug.LogError("LanguageManager: Couldn't find dictionary file at \"Resources/" + resourcesPath + "\"."); Debug.Break(); } Resources.UnloadAsset(textAsset); }