public EDFFile(string fileName, DataFiles whichFile) { if (!File.Exists(fileName)) throw new FileNotFoundException("File does not exist!", fileName); Data = new Dictionary<int, string>(); if (whichFile == DataFiles.CurseFilter) { string[] lines = File.ReadAllLines(fileName); int i = 0; foreach (string encoded in lines) { string decoded = _decodeDatString(encoded, whichFile); string[] curses = decoded.Split(':'); foreach (string curse in curses) Data.Add(i++, curse); } } else { string[] lines = File.ReadAllLines(fileName, Encoding.Default); int i = 0; foreach (string encoded in lines) Data.Add(i++, _decodeDatString(encoded, whichFile)); } }
private Xls.TableCodes _GetTableCodeFromTableIndex(int tableIndex) { if (tableIndex < 0) { return(Xls.TableCodes.Null); } if (_excelIndexToCodeList == null) { DataFile excelTables; if (!DataFiles.TryGetValue(ExcelTablesStringId, out excelTables)) { return(0); } _excelIndexToCodeList = new List <Xls.TableCodes>(); foreach (ExcelTablesRow excelTable in excelTables.Rows) { _excelIndexToCodeList.Add((Xls.TableCodes)excelTable.code); } } if (tableIndex >= _excelIndexToCodeList.Count) { return(Xls.TableCodes.Null); } return(_excelIndexToCodeList[tableIndex]); }
public void WhenIGetShoppingBagPaymentsDataFromFile(string file) { string data = DataFiles.ReadJsonDataFile(file); ShoppingBag bag = ObjectSerializer.DeserializeToObject <ShoppingBag>(data); sharedStorage.SetSharedInfo(ContextTag.ShoppingBagPaymentData, bag); }
public EDFFile(string fileName, DataFiles whichFile) { if (!File.Exists(fileName)) { throw new FileNotFoundException("File does not exist!", fileName); } Data = new Dictionary <int, string>(); if (whichFile == DataFiles.CurseFilter) { string[] lines = File.ReadAllLines(fileName); int i = 0; foreach (string encoded in lines) { string decoded = _decodeDatString(encoded, whichFile); string[] curses = decoded.Split(':'); foreach (string curse in curses) { Data.Add(i++, curse); } } } else { string[] lines = File.ReadAllLines(fileName, Encoding.Default); int i = 0; foreach (string encoded in lines) { Data.Add(i++, _decodeDatString(encoded, whichFile)); } } }
/// <summary> /// Retrieves an Excel Table from its Code value. If it's not loaded, then it will be loaded and returned. /// </summary> /// <param name="code">The code of the Excel Table to retrieve.</param> /// <returns>The Excel Table as a DataTable, or null if not found.</returns> public ExcelFile GetExcelTableFromCode(Xls.TableCodes code) { if (DataFiles == null || DataFiles.ContainsKey(ExcelTablesStringId) == false || code == Xls.TableCodes.Null) { return(null); } if (_excelCodeToTable == null) { ExcelFile excelTables = (ExcelFile)DataFiles[ExcelTablesStringId]; _excelCodeToTable = new Dictionary <Xls.TableCodes, ExcelFile>(); foreach (ExcelTablesRow excelTablesRow in excelTables.Rows) { DataFile dataFile; if (DataFiles.TryGetValue(excelTablesRow.name, out dataFile)) { _excelCodeToTable[(Xls.TableCodes)excelTablesRow.code] = (ExcelFile)dataFile; } } } ExcelFile excelTable; return(_excelCodeToTable.TryGetValue(code, out excelTable) ? excelTable : null); }
public async void LoadData() { DataFiles.Clear(); await Task.Run(delegate { try { _subjectService.LoadSubjectData(DataFolder, _regionService.GetNodeCount()); // TODO: Get the ROI number from somewhere else?!? var subjects = _subjectService.GetSubjects(); foreach (var subject in subjects) { foreach (var graph in subject.Graphs) { var df = IoC.Get <DataFileViewModel>(); df.Title = graph.Value.DataSource; df.SubjectId = subject.SubjectId; DataFiles.Add(df); } } } catch (Exception) { } }); }
/// <summary> /// Obtains an int value from an excel table using a StringId, column name, and row index. /// Returns 0x4C494146 on fail (will output as 'FAIL'). /// </summary> /// <param name="stringId">An Excel Table StringId.</param> /// <param name="rowIndex">The row index to obtain the value from.</param> /// <param name="colName">The column name to check.</param> /// <returns></returns> public int GetExcelIntFromStringId(String stringId, int rowIndex, String colName) { if (DataFiles == null || String.IsNullOrEmpty(stringId) || DataFiles.ContainsKey(stringId) == false) { return(0x4C494146); } ExcelFile excelTable = DataFiles[stringId] as ExcelFile; if (excelTable == null) { return(0x4C494146); } if (rowIndex < 0 || rowIndex >= excelTable.Rows.Count) { return(0x4C494146); } ObjectDelegator excelDelegator = DataFileDelegators[stringId]; Object row = excelTable.Rows[rowIndex]; Object value = excelDelegator[colName](row); if (value is int) { return((int)value); } return((int)(short)value); }
public void GivenIGetStorefrontDataFromFile(string file) { string data = DataFiles.ReadJsonDataFile(file); StorefrontData storefront = ObjectSerializer.DeserializeToObject <StorefrontData>(data); sharedStorage.SetSharedInfo(ContextTag.GetStorefrontData, storefront); }
internal void AddDataFile(DataFile df) { if (!DataFiles.ContainsKey(df.Name)) { DataFiles.Add(df.Name, df); } }
public void GivenIGetPickupDataFromFile(string file) { string data = DataFiles.ReadJsonDataFile(file); ProfileSettings settings = ObjectSerializer.DeserializeToObject <ProfileSettings>(data); sharedStorage.SetSharedInfo(ContextTag.SettingData, settings); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); mContent = DataFiles.Load(); mPropertyGrid.SelectedObject = new FeatureCreepGeneratorOptions(); }
/// <summary> /// Adds the given file to the mod install log. /// </summary> /// <remarks> /// Adding a file to a mod's install log indicates that said file was installed /// as part of the mod. /// </remarks> /// <param name="p_strDataPath">The file that was installed for the mod.</param> internal void AddFile(string p_strDataPath) { var strNormalizedPath = NormalizePath(p_strDataPath); if (!ListContains(DataFiles, strNormalizedPath)) { DataFiles.Add(strNormalizedPath); } }
public override void HandlerThunkStr(string whence, string str) { if (Parent.FlushOnNextDataFile) { DataFiles.Clear(); Parent.FlushOnNextDataFile = false; } DataFiles.Add(str); }
partial void ViewFile_PreprocessQuery(int?FileId, ref IQueryable <DataFile> query) { var key = FileId ?? -1; var file = DataFiles.Where(f => f.DataFileId.Equals(key)).FirstOrDefault(); var filePath = String.Format(@"\\san\Forensics\UserData\Lists\{0}", file.Filename); OpenToViewFile(filePath); }
private void GivenFileHasStringForResourceID(DataFiles file, EOResourceID id, string str) { if (!_dataFileProvider.DataFiles.ContainsKey(file)) { _dataFileProvider.DataFiles.Add(file, Mock.Of <IEDFFile>(x => x.Data == new Dictionary <int, string>())); } _dataFileProvider.DataFiles[file].Data[(int)id] = str; }
public void AddDataFile(string fileName, string fileColmumn, Variable variable, string value) { //me fijo si ya exite el arcihvo if (!DataFiles.ContainsKey(fileName)) { DataFiles.Add(fileName, new DataFile(fileName)); } DataFiles[fileName].AddColumn(fileColmumn, variable, value); }
/// <summary> /// Retrieves a DataFile from the DataFiles list. /// </summary> /// <param name="stringId">The stringID of the DataFile.</param> /// <returns>Matching DataFile if it exists.</returns> public DataFile GetDataFile(String stringId) { if (DataFiles == null) { return(null); } DataFile dataFile; return((DataFiles.TryGetValue(stringId, out dataFile)) ? dataFile : null); }
public DateTimeRange GetDataFilesTimeRange() { if (DataFiles.Count > 0) { return(new DateTimeRange(DataFiles[0].DataStart, DataFiles.Last().DataEnd)); } else { return(new DateTimeRange(DateTime.MinValue, DateTime.MinValue)); } }
/// <summary> /// Checks if a data table has a specified column name. /// </summary> /// <param name="stringId">The StringId of the data table to check.</param> /// <param name="colName">The column name to check for.</param> /// <returns>True if the table has the column.</returns> public bool DataTableHasColumn(String stringId, String colName) { if (DataFiles == null || !DataFiles.ContainsKey(stringId)) { return(false); } ObjectDelegator objectDelegator = DataFileDelegators[stringId]; return(objectDelegator.ContainsGetFieldDelegate(colName)); }
private string _decodeDatString(string input, DataFiles whichFile) { //unencrypted if (whichFile == DataFiles.Credits || whichFile == DataFiles.Checksum) { return(input); } string ret = ""; for (int i = 0; i < input.Length; i += 2) { ret += input[i]; } //if there are an even number of characters start with the last one //otherwise start with the second to last one int startIndex = input.Length - (input.Length % 2 == 0 ? 1 : 2); for (int i = startIndex; i >= 0; i -= 2) { ret += input[i]; } if (whichFile == DataFiles.CurseFilter) { return(ret); } StringBuilder sb = new StringBuilder(ret); //additional unscrambling (testing/WIP!) //adjacent ascii char values that are multiples of 7, starting at ? (63), should be flipped for (int i = 0; i < sb.Length; ++i) { int next = i + 1; if (next < sb.Length) { char c1 = sb[i], c2 = sb[next]; int ch1 = Convert.ToInt32(c1); int ch2 = Convert.ToInt32(c2); if (ch1 % 7 == 0 && ch2 % 7 == 0) { sb[i] = c2; sb[next] = c1; } } } return(sb.ToString()); }
public String GetExcelStringFromRowIndex(Xls.TableCodes code, int rowIndex, int colIndex = 0) { if (DataFiles == null || DataFiles.ContainsKey(ExcelTablesStringId) == false || rowIndex < 0) { return(null); } ExcelFile excelTable = GetExcelTableFromCode(code); String stringVal = _GetExcelStringFromExcelFile(excelTable, rowIndex, colIndex); return(stringVal); }
public FileListItem(DataFiles inner) { _inner = inner; var extensions = inner.Files.Select(item => item.Extension).Distinct(); var extensionsAsString = string.Join(", ", extensions); Extensions = extensionsAsString; var properties = inner.Files.Select(item => item.Property).Select(item => string.IsNullOrWhiteSpace(item) ? "''" : item); var propertiesAsString = string.Join(", ", properties); Properties = propertiesAsString; }
/// <summary> /// Get the details of a specific data file used by this engine. /// </summary> /// <param name="dataFileIdentifier"> /// The identifier of the data file to get meta data for. /// This parameter is ignored if the engine only has one data file. /// </param> /// <returns> /// The meta data associated with the specified data file. /// Returns null if the engine has no associated data files. /// </returns> public IAspectEngineDataFile GetDataFileMetaData(string dataFileIdentifier = null) { if (DataFiles.Count == 0) { return(null); } else if (DataFiles.Count == 1) { return(DataFiles.Single()); } else { return(DataFiles.Single(f => f.Identifier == dataFileIdentifier)); } }
/// <summary> /// Called when update data is available in order to get the /// engine to refresh it's internal data structures. /// This overload is used if the data is a physical file on disk. /// </summary> /// <param name="dataFileIdentifier"> /// The identifier of the data file to update. /// This engine only uses one data file so this parameter is ignored. /// </param> public override void RefreshData(string dataFileIdentifier) { var dataFile = DataFiles.Single(); if (_engine == null) { _engine = _swigFactory.CreateEngine(dataFile.DataFilePath, _config, _propertiesConfigSwig); } else { _engine.refreshData(); } GetEngineMetaData(); RefreshCompleted?.Invoke(this, null); }
/// <summary> /// Gets the RowIndex of a row containing a string, using the column name to search by. /// Returns -2 on error, -1 on not found /// </summary> /// <param name="stringId">An Excel Table StringId.</param> /// <param name="value">The value to search for.</param> /// <param name="colName">The column name to check.</param> /// <returns>Row index string found in column colName. (-2=error, -1=not found)</returns> public int GetExcelRowIndexFromStringId(String stringId, String value, String colName) { if (DataFiles == null || String.IsNullOrEmpty(stringId) || DataFiles.ContainsKey(stringId) == false) { return(-2); } ExcelFile excelTable = DataFiles[stringId] as ExcelFile; if (excelTable == null) { return(-2); } ObjectDelegator excelDelegator = DataFileDelegators[stringId]; ObjectDelegator.FieldDelegate fieldDelegate = excelDelegator.GetFieldDelegate(colName); if (fieldDelegate == null) { return(-2); } bool isStringField = (fieldDelegate.FieldType == typeof(String)); int rowIndex = -1; foreach (Object row in excelTable.Rows) { rowIndex++; if (isStringField) { if ((String)fieldDelegate.GetValue(row) == value) { return(rowIndex); } } else { int offset = (int)fieldDelegate.GetValue(row); if (excelTable.ReadStringTable(offset) == value) { return(rowIndex); } } } return(-1); }
/// <summary> /// Called by the 'BuildEngine' method to handle /// creation of the engine instance. /// </summary> /// <param name="properties"></param> /// <returns> /// An <see cref="IAspectEngine"/>. /// </returns> protected override DeviceDetectionHashEngine NewEngine( List <string> properties) { if (DataFiles.Count != 1) { throw new PipelineConfigurationException( "This builder requires one and only one configured file " + $"but it has {DataFileConfigs.Count}"); } var dataFile = DataFiles.First(); // We remove the data file configuration from the list. // This is because the on-premise engine builder base class // adds all the data file configs after engine creation. // However, the device detection data files are supplied // directly to the constructor. // Consequently, we remove it here to stop it from being added // again by the base class. DataFiles.Remove(dataFile); // Update the swig configuration object. SwigConfig.setUseUpperPrefixHeaders(false); if (dataFile.Configuration.CreateTempCopy && String.IsNullOrEmpty(TempDir) == false) { using (var tempDirs = new VectorStringSwig()) { tempDirs.Add(TempDir); SwigConfig.setTempDirectories(tempDirs); } SwigConfig.setUseTempFile(true); } // Create swig property configuration object. IRequiredPropertiesConfigSwigWrapper propertyConfig = null; using (var vProperties = new VectorStringSwig(properties)) { propertyConfig = SwigFactory.CreateRequiredProperties(vProperties); } return(new DeviceDetectionHashEngine( _loggerFactory, dataFile, SwigConfig, propertyConfig, CreateAspectData, TempDir, SwigFactory)); }
private void readJsonDataFiles(JToken node, ReadingOptions options) { DataFiles.Clear(); if (!options.DataFiles) { return; } JArray dataFilesArray = node.Value <JArray>("dataFiles"); if (dataFilesArray == null) { return; } DataFiles.Capacity = dataFilesArray.Count; DataFiles.AddRange(dataFilesArray.Values <string>()); }
public void AlumnoBinario() { Alumno al = new Alumno(); Alumno alum = new Alumno(7, "Matias", "Suarez", 32, 454547, "acalavuelta 2"); DataFiles.SerializarAlumnoBinario(alum, "APROBADO"); DirectoryInfo di = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\SegundoParcialUtn\\JardinUtn\\Serializaciones\\Aprobados"); foreach (var fi in di.GetFiles("Suarez_Matias*.aut")) { al = DataFiles.LeerAlumnoBinario(fi.FullName); } Assert.IsNotNull(al); }
/// <summary> /// Called by the 'BuildEngine' method to handle /// anything that needs doing before the engine is built. /// </summary> protected override void PreCreateEngine() { // Register any configured files with the data update service. // Any files that have the 'update on startup' flag set // will be updated now. // Create the auto-update configuration and register it. foreach (var dataFileConfig in DataFileConfigs) { var dataFile = NewAspectEngineDataFile(); dataFile.Identifier = dataFileConfig.Identifier; dataFile.Configuration = dataFileConfig; dataFile.TempDataDirPath = TempDir; if (dataFileConfig.AutomaticUpdatesEnabled || dataFileConfig.UpdateOnStartup || dataFileConfig.FileSystemWatcherEnabled) { if (_dataUpdateService == null) { List <string> features = new List <string>(); if (dataFileConfig.AutomaticUpdatesEnabled) { features.Add("auto update"); } if (dataFileConfig.UpdateOnStartup) { features.Add("update on startup"); } if (dataFileConfig.FileSystemWatcherEnabled) { features.Add("file system watcher"); } throw new PipelineException( $"Some enabled features ({string.Join(",", features)}) " + "require an IDataUpdateService but one has not been supplied. " + "This can be corrected by passing an IDataUpdateService " + "instance to the engine builder constructor. " + "If building from configuration, an IServiceProvider " + "instance, able to resolve an IDataUpdateService, " + "must be passed to the pipeline builder."); } _dataUpdateService.RegisterDataFile(dataFile); } DataFiles.Add(dataFile); } }
static Inflection() { Inflections = InflectionProcess.FromFile(DataFiles.PathTo("Inflections", "Regular nouns")); foreach (var entry in File.ReadAllLines(DataFiles.PathTo("Inflections", "Irregular nouns"))) { var split = entry.Split('\t'); var singular = split[0]; var plural = split[1]; IrregularPlurals[singular] = plural; IrregularSingulars[plural] = singular; } IrregularVerbs = new Spreadsheet(DataFiles.PathTo( "Inflections", "Irregular verbs", ".csv"), "Base form"); }
/// <summary> /// Constructor de la clase, instancia listas y obtiene datos de la db /// </summary> public JardinMain() { InitializeComponent(); alumnosCola = new Queue <Alumno>(); alumnosCola = DataSQL.LeerAlumnosSQL(); aulasLista = new List <Aula>(); aulasLista = DataSQL.LeerAulasSQL(); docentesLista = new List <Docente>(); DataFiles.LeerDocentesXML(); LlenarCola(alumnosCola); /*docentesLista.Add(new Docente("Alfredo", "ibanez", 45, 20000, "asdasdasd", 2, "masculino", "*****@*****.**")); * docentesLista.Add(new Docente("B", "ibanez", 45, 20001, "asdasdasd", 3, "masculino", "*****@*****.**")); * docentesLista.Add(new Docente("C", "dada", 45, 20002, "asdasdasd", 4, "masculino", "*****@*****.**")); * docentesLista.Add(new Docente("D", "ibansdsdez", 45, 20003, "asdasdasd", 5, "masculino", "*****@*****.**")); * docentesLista.Add(new Docente("F", "ibanerweez", 45, 20004, "asdasdasd", 6, "masculino", "*****@*****.**"));*/ }
private string _decodeDatString(string input, DataFiles whichFile) { //unencrypted if (whichFile == DataFiles.Credits || whichFile == DataFiles.Checksum) return input; string ret = ""; for (int i = 0; i < input.Length; i += 2) ret += input[i]; //if there are an even number of characters start with the last one //otherwise start with the second to last one int startIndex = input.Length - (input.Length % 2 == 0 ? 1 : 2); for (int i = startIndex; i >= 0; i -= 2) ret += input[i]; if (whichFile == DataFiles.CurseFilter) return ret; StringBuilder sb = new StringBuilder(ret); //adjacent ascii char values that are multiples of 7 should be flipped for (int i = 0; i < sb.Length; ++i) { int next = i + 1; if (next < sb.Length) { char c1 = sb[i], c2 = sb[next]; int ch1 = Convert.ToInt32(c1); int ch2 = Convert.ToInt32(c2); if (ch1 % 7 == 0 && ch2 % 7 == 0) { sb[i] = c2; sb[next] = c1; } } } return sb.ToString(); }