/// <summary> /// Constructor of the view model class. Initializes all the required members with the passed references. /// </summary> /// <param name="volumeCalculationHelper">Helps to calculate the volume.</param> /// <param name="volumeCalculatorModel">This is the data class. This holds the required data.</param> /// <param name="readFile">Helps to read a file.</param> public VolumeCalculatorVM(IVolumeCalculationHelper volumeCalculationHelper, IVolumeCalculatorModel volumeCalculatorModel, IReadFile readFile) { m_VolumeCalculationHelper = volumeCalculationHelper; m_VolumeCalculatorModel = volumeCalculatorModel; m_ReadCSV = readFile; OpenDialogCmd = new OpenDialogCommand(null, SetImportText); }
public static sviParser OpenSVI([DefaultVar] ppParser parser, string name) { for (int i = 0; i < parser.Subfiles.Count; i++) { if (parser.Subfiles[i].Name == name) { IReadFile subfile = parser.Subfiles[i] as IReadFile; if (subfile != null) { return(new sviParser(subfile.CreateReadStream(), subfile.Name)); } if (parser.Subfiles[i] is sviParser) { return((sviParser)parser.Subfiles[i]); } else if (parser.Subfiles[i] is ToolOutputParser) { ToolOutputParser toolOutputParser = (ToolOutputParser)parser.Subfiles[i]; return(new sviParser(new MemoryStream(toolOutputParser.contents), toolOutputParser.Name)); } break; } } return(null); }
private void soundSubfilesList_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { try { if (!soundLib.isLoaded()) { return; } if (e.IsSelected) { IReadFile subfile = (IReadFile)e.Item.Tag; Stream stream = (Stream)Gui.Scripting.RunScript(EditorVar + ".ReadSubfile(name=\"" + subfile.Name + "\")", false); byte[] soundBuf; using (BinaryReader reader = new BinaryReader(stream)) { soundBuf = reader.ReadToEnd(); } soundLib.Play(e.Item.Text, soundBuf); } else { soundLib.Stop(e.Item.Text); } } catch (Exception ex) { Utility.ReportException(ex); } }
public List <Employee> CheckFile(ILog log, IReadFile read) { if (read.ReadLine() == "XML") { log = new LogXml(); if (File.Exists("employees.xml")) { list = (List <Employee>)log.LogOut(); } else { list = new List <Employee>(); } } if (read.ReadLine() == "BIN") { log = new LogBinary(); if (File.Exists("employees.dat")) { list = (List <Employee>)log.LogOut(); } else { list = new List <Employee>(); } } //list.Add(new Employee("AB325721", "Иван", "Кононов", "*****@*****.**", "+38(099)345-45-67", false, new DateTime(1990, 9, 07), "Менеджер", 500, new DateTime(2015, 8, 23))); //list.Add(new Employee("АК859062", "Антонина", "Громова", "*****@*****.**", "+38(097)256-15-68", true, new DateTime(1972, 7, 15), "Технолог", 1200, new DateTime(2010, 4, 19))); //list.Add(new Employee("AН216084", "Петр", "Логинов", "*****@*****.**", "+38(095)213-33-13", false, new DateTime(1984, 2, 20), "Маркетолог", 800, new DateTime(2014, 9, 03))); //list.Add(new Employee("ВК114267", "Ирина", "Фадеева", "*****@*****.**", "+38(050)468-09-77", true, new DateTime(1976, 1, 09), "Бухгалтер", 1500, new DateTime(2011, 1, 13))); //list.Add(new Employee("ВН307643", "Семен", "Сорокин", "*****@*****.**", "+38(066)178-89-55", true, new DateTime(1978, 4, 26), "Юрист", 1000, new DateTime(2013, 10, 28))); return(list); }
private void imageSubfilesList_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { try { if (e.IsSelected) { IReadFile subfile = (IReadFile)e.Item.Tag; ImportedTexture image; string stream = EditorVar + ".ReadSubfile(name=\"" + subfile.Name + "\")"; if (Path.GetExtension(subfile.Name).ToLowerInvariant() == ".ema") { image = (ImportedTexture)Gui.Scripting.RunScript(Gui.ImageControl.ImageScriptVariable + " = ImportEmaTexture(stream=" + stream + ", name=\"" + subfile.Name + "\")"); } else { image = (ImportedTexture)Gui.Scripting.RunScript(Gui.ImageControl.ImageScriptVariable + " = ImportTexture(stream=" + stream + ", name=\"" + subfile.Name + "\")"); } Gui.ImageControl.Image = image; } } catch (Exception ex) { Utility.ReportException(ex); } }
List <Log> ILogToObject.LogToObj(IReadFile read, String url) { StreamReader reader = new StreamReader(read.Read(url)); List <Log> listOfLogs = new List <Log>(); string line; while ((line = reader.ReadLine()) != null) { string[] lineOfLog = line.Split('|'); string[] methodAndPath = lineOfLog[3].Split(" "); string provider = "\"MINHA CDN\""; string method = methodAndPath[0].Replace("\"", ""); int statusCode = Convert.ToInt32(lineOfLog[1]); string uri = methodAndPath[1]; int timeTaken = Convert.ToInt32(lineOfLog[0]); string cacheStatus = lineOfLog[2]; int responseSize = Decimal.ToInt32(Convert.ToDecimal(lineOfLog[4].Replace(".", ","))); Log logExists = listOfLogs.Find(obj => obj.HttpMethod1 == method && obj.UriPath1 == uri); if (logExists != null) { cacheStatus = "REFRESH_" + logExists.CacheStatus1; } Log log = new Log(provider, method, statusCode, uri, timeTaken, responseSize, cacheStatus); listOfLogs.Add(log); } reader.Close(); return(listOfLogs); }
public List <Employee> TickFile(ILog log, IReadFile read) { if (read.ReadLine() == "XML") { log = new LogXml(); if (File.Exists("employees.xml")) { list = (List <Employee>)log.LogOut(); } else { list = new List <Employee>(); } } if (read.ReadLine() == "BIN") { log = new LogBinary(); if (File.Exists("employees.dat")) { list = (List <Employee>)log.LogOut(); } else { list = new List <Employee>(); } } return(list); }
public static ToolOutputParser OpenToolOutput([DefaultVar] ppParser parser, string name) { for (int i = 0; i < parser.Subfiles.Count; i++) { if (parser.Subfiles[i].Name == name) { IReadFile subfile = parser.Subfiles[i] as IReadFile; if (subfile != null) { return(new ToolOutputParser(subfile.CreateReadStream(), subfile.Name)); } IWriteFile writeFile = parser.Subfiles[i] as IWriteFile; if (writeFile != null) { using (MemoryStream memStream = new MemoryStream()) { writeFile.WriteTo(memStream); memStream.Position = 0; ToolOutputParser outParser = new ToolOutputParser(memStream, writeFile.Name); outParser.readFromOtherParser = true; return(outParser); } } break; } } return(null); }
public void ToProject() { operation = new Operations(); read = new LogRead(); check = new CheckFile(); draw = new DrawTableResults(); new Menu().Show(operation, read, check, draw); }
public ViewModelOperation() { //CancelToken(); _getFilePath = new GetPathAllFiles(); _readFile = new BinaryReadFile(); _writeFile = new WriteXmlFile(); _filesSize = new BindingList <ReadFileResult>(); }
public void Setup() { _fileOpener = A.Fake <IOpenFile>(); _fileReader = A.Fake <IReadFile>(); _fileWriter = A.Fake <IWriteFile>(); _csvReaderWriter = new CSVReaderWriter(_fileOpener, _fileReader, _fileWriter); }
/// <summary> /// Creates a new instance of <see cref="DefaultBlobstoreController"/> /// </summary> /// <param name="fileEnlister">Dependency injection for <see cref="IEnlistFiles"/></param> /// <param name="fileReader">Dependency injection for <see cref="IReadFile"/></param> /// <param name="fileWriter">Dependency injection for <see cref="IWriteFile"/></param> public DefaultBlobstoreController( IEnlistFiles fileEnlister, IReadFile fileReader, IWriteFile fileWriter) { this.fileEnlister = fileEnlister; this.fileReader = fileReader; this.fileWriter = fileWriter; }
public DefaultBlobstoreControllerTest() { this.fileEnlister = A.Fake<IEnlistFiles>(); this.fileReader = A.Fake<IReadFile>(); this.fileWriter = A.Fake<IWriteFile>(); this.testee = new DefaultBlobstoreController( this.fileEnlister, this.fileReader, this.fileWriter); }
public void BuildProject() { operations = new OperationsMenu(); validate = new InputValidation(); read = new LogRead(); check = new CheckFileExists(); draw = new DrawTableResults(); new Menu().Show(operations, validate, read, check, draw); }
public PPSource(IReadFile subfile) { this.subfile = subfile; using (Stream stream = GetStream()) { _md5 = Utility.GetMd5(stream); _size = (uint)stream.Position; } }
public DataProviderWrapperService(IReadFile readFileProvider, IEnumerable <IWriteFile> writeFileProviders, IEnumerable <IReadCmsItem> readCmsItemProviders, IEnumerable <IWriteCmsItem> writeCmsItemProviders, IEnumerable <IWriteCmsItemInterceptor> writeCmsItemInterceptors ) { this.readFileProvider = readFileProvider; this.writeFileProviders = writeFileProviders; this.readCmsItemProviders = readCmsItemProviders; this.writeCmsItemProviders = writeCmsItemProviders; this.writeCmsItemInterceptors = writeCmsItemInterceptors; }
public static lstParser OpenLST([DefaultVar] ppParser parser, string name) { for (int i = 0; i < parser.Subfiles.Count; i++) { if (parser.Subfiles[i].Name == name) { IReadFile subfile = parser.Subfiles[i] as IReadFile; if (subfile != null) { return(new lstParser(subfile.CreateReadStream(), subfile.Name)); } break; } } return(null); }
public static reaParser OpenREA([DefaultVar] fpkParser parser, string name) { for (int i = 0; i < parser.Subfiles.Count; i++) { if (parser.Subfiles[i].Name == name) { IReadFile subfile = parser.Subfiles[i] as IReadFile; if (subfile != null) { return(new reaParser(subfile.CreateReadStream(), subfile.Name, parser.FilePath)); } break; } } return(null); }
public static Frames Load(string path, IReadFile readFile) { Frames frames = new Frames(FrameCountRule.GetCount()); try { readFile.Open(path); string content = readFile.ReadLine(); foreach (string str in content.Split(',')) { if (str == "") break; frames = RollService.Roll(frames, int.Parse(str)); } } finally { readFile.Close(); } return frames; }
public ChunkFile(IReadFile _pp, string parent, uint size) { pp = _pp; name = (parent + "/" + pp.Name); if (name.ToLower().EndsWith(".wav")) { var tmp = new byte[44]; pp.CreateReadStream().Read(tmp, 0, 44); if (checkWav(tmp) != 0) { naked = true; flags |= Flags.OPUS; } } if (!naked) { flags |= Flags.ZSTD; } orig_size = size; var hasher = MD5.Create(); md5 = BitConverter.ToInt64(hasher.ComputeHash(pp.CreateReadStream()), 0); }
public static Stream GetReadStream(IWriteFile iw) { Stream str; if (iw is MemSubfile) { MemSubfile m = iw as MemSubfile; str = m.CreateReadStream(); } else if (iw is IReadFile) { IReadFile p = iw as IReadFile; str = p.CreateReadStream(); } else { str = new MemoryStream(); iw.WriteTo(str); str.Position = 0; } return(str); }
public XmlFetchUsersData(IReadFile fileReader) { _fileReader = fileReader; }
public void Show(IOperations operations, IValidate validate, IReadFile read, ICheckFile check, IDrawTable draw) { operations.Employees = check.CheckFile(Log, read); while (true) { Console.Clear(); Console.WriteLine("Введите команду: "); string command = Console.ReadLine(); switch (command.ToLower()) { case "add": while (true) { Console.Clear(); Console.WriteLine("Введите паспортные данные сотрудника: "); pasp = Console.ReadLine(); if (validate.Check(pasp, pasport) == false) { Console.WriteLine("Некорректный ввод паспортных данных сотрудника: "); Console.ReadKey(); } else { break; } } if (operations.Employees.Exists(x => x.PassportData == pasp) == false) { string name; while (true) { Console.Clear(); Console.WriteLine("Введите имя сотрудника (не более 10 символов): "); name = Console.ReadLine(); if (name.Length > 10) { Console.WriteLine("Некорректный ввод имени сотрудника!"); Console.ReadKey(); } else { break; } } string surname; while (true) { Console.Clear(); Console.WriteLine("Введите фамилию сотрудника (не более 15 символов): "); surname = Console.ReadLine(); if (surname.Length > 15) { Console.WriteLine("Некорректный ввод фамилии сотрудника!"); Console.ReadKey(); } else { break; } } string email; while (true) { Console.Clear(); Console.WriteLine("Введите email сотрудника: "); email = Console.ReadLine(); string mail = @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"; if (validate.Check(email, mail) == false) { Console.WriteLine("Некорректный ввод почты сотрудника: "); Console.ReadKey(); } else { break; } } string tel; while (true) { Console.Clear(); Console.WriteLine("Введите телефон сотрудника: "); tel = Console.ReadLine(); string tel1 = @"^\+\d{2}\(\d{3}\)\d{3}-\d{2}-\d{2}$"; if (validate.Check(tel, tel1) == false) { Console.WriteLine("Некорректный ввод номера телефона сотрудника: "); Console.ReadKey(); } else { break; } } bool statusF; while (true) { Console.Clear(); Console.WriteLine("Введите 'False', если сотрудник холост/не замужем, в противном случае - введите 'True': "); text = Console.ReadLine(); if (Boolean.TryParse(text, out statusF) == false) { Console.WriteLine("Некорректный ввод семейного положения сотрудника: "); Console.ReadKey(); } else { break; } } DateTime bDate; while (true) { Console.Clear(); Console.WriteLine("Введите дату рождения сотрудника в формате dd.mm.yy: "); text = Console.ReadLine(); if (DateTime.TryParse(text, out bDate) == false) { Console.WriteLine("Некорректный ввод даты рождения сотрудника: "); Console.ReadKey(); } else { break; } } string position; while (true) { Console.Clear(); Console.WriteLine("Введите должность сотрудника (не более 18 символов): "); position = Console.ReadLine(); if (surname.Length > 18) { Console.WriteLine("Некорректная длина пасортных данных сотрудника!"); Console.ReadKey(); } else { break; } } decimal salary; while (true) { Console.Clear(); Console.WriteLine("Введите должностной оклад сотрудника: "); text = Console.ReadLine(); if (Decimal.TryParse(text, out salary) == false || salary < 0) { Console.WriteLine("Некорректный ввод должностного оклада сотрудника: "); Console.ReadKey(); } else { break; } } DateTime eDate; while (true) { Console.Clear(); Console.WriteLine("Введите дату приема на работу сотрудника в формате dd.mm.yy: "); text = Console.ReadLine(); if (DateTime.TryParse(text, out eDate) == false) { Console.WriteLine("Некорректный ввод даты приема на работу сотрудника: "); Console.ReadKey(); } else { break; } } operations.AddEmp(pasp, name, surname, email, tel, statusF, bDate, position, salary, eDate); Console.WriteLine("Сотрудник успешно добавлен в базу данных."); } else { Console.WriteLine("Сотрудник с такими паспортными данными уже существует!"); } Console.ReadKey(); break; case "del": while (true) { Console.Clear(); Console.WriteLine("Введите паспортные данные сотрудника: "); pasp = Console.ReadLine(); if (validate.Check(pasp, pasport) == false) { Console.WriteLine("Некорректный ввод паспортных данных сотрудника: "); Console.ReadKey(); } else { break; } } if (operations.Employees.Exists(x => x.PassportData == pasp)) { operations.Del(pasp); Console.WriteLine("Удаление прошло успешно."); } else { Console.WriteLine("Сотрудника с такими паспортными данными не существует!"); } Console.ReadKey(); break; case "see_all": Console.WriteLine(draw.MakeTableResults(operations.Employees)); Console.ReadKey(); break; case "find_emp": while (true) { Console.Clear(); Console.WriteLine("Введите паспортные данные сотрудника: "); pasp = Console.ReadLine(); if (validate.Check(pasp, pasport) == false) { Console.WriteLine("Некорректный ввод паспортных данных сотрудника: "); Console.ReadKey(); } else { break; } } Console.Clear(); if (operations.Employees.Exists(x => x.PassportData == pasp)) { Console.WriteLine(operations.FindEmployee(pasp).ToString()); } else { Console.WriteLine("Сотрудника с такими паспортными данными не существует!"); } Console.ReadKey(); break; case "sort_salary": decimal min; while (true) { Console.Clear(); Console.WriteLine("Введите нижнюю границу зарплаты для сортировки: "); text = Console.ReadLine(); if (Decimal.TryParse(text, out min) == false || min < 0) { Console.WriteLine("Некорректный ввод данных."); Console.ReadKey(); } else { break; } } Console.WriteLine(draw.MakeTableResults(operations.SortSalary(min))); Console.ReadKey(); break; case "sort_date": string date; DateTime dateMin; DateTime dateMax; while (true) { Console.Clear(); Console.WriteLine("Введите начало периода сортировки: "); text = Console.ReadLine(); Console.WriteLine("Введите конец периода сортировки: "); date = Console.ReadLine(); if (DateTime.TryParse(text, out dateMin) == false || DateTime.TryParse(date, out dateMax) == false) { Console.WriteLine("Некорректный ввод данных."); Console.ReadKey(); } else { break; } } Console.WriteLine(draw.MakeTableResults(operations.SortDateOfEmployment(dateMin, dateMax))); Console.ReadKey(); break; case "exit": if (read.ReadLine() == "XML") { Log = new LogXml(); } if (read.ReadLine() == "BIN") { Log = new LogBinary(); } Log.LogSave(operations.Employees); return; } if (command.ToLower() != "add" && command.ToLower() != "del" && command.ToLower() != "see_all" && command.ToLower() != "find_emp" && command.ToLower() != "sort_salary" && command.ToLower() != "sort_date" && command.ToLower() != "exit") { Help(); } } }
public Groups(IReadFile loadedFile) { this.loadedFile = loadedFile; }
public void Show(IOperation operation, IReadFile read, ICheckFile check, IDrowTable draw) { // operation.Employees = check.CheckFile(Log, read); operation.Employees = check.TickFile(Log, read); string alias; while (true) { Console.Clear(); Console.WriteLine("Введите команду: "); string command = Console.ReadLine(); switch (command.ToLower()) { case "add": Console.Clear(); Console.WriteLine("Введите псевдоним сотрудника: "); alias = Console.ReadLine(); if (alias.Length >= 15) { Console.WriteLine("Приносим извенения, но ваш псевдоним слишком длинный."); Console.ReadKey(); continue; } //if (operation.Employees.Exists(x => x.Alias == alias)) //{ string name; while (true) { Console.Clear(); Console.WriteLine("Введите имя сотрудника: "); name = Console.ReadLine(); if (name.Length >= 16) { Console.WriteLine("Приносим извенения, но имя слишком длинное слишком длинное. Пожалуйста, используйте сокращенную форму имени."); Console.ReadKey(); } else { break; } } string surname; while (true) { Console.Clear(); Console.WriteLine("Введите фамилию сотрудника: "); surname = Console.ReadLine(); if (surname.Length >= 18) { Console.WriteLine("Приносим извенения, но фамилия слишком длинное слишком длинное. Пожалуйста, используйте сокращенную форму фамилии."); Console.ReadKey(); } else { break; } } string department; while (true) { Console.Clear(); Console.WriteLine("Введите отдел сотрудника: "); department = Console.ReadLine(); if (surname.Length >= 22) { Console.WriteLine("Некорректный ввод названия отдела."); Console.ReadKey(); } else { break; } } string position; while (true) { Console.Clear(); Console.WriteLine("Введите дожность сотрудника: "); position = Console.ReadLine(); if (surname.Length >= 20) { Console.WriteLine("Некорректный наименования должности."); Console.ReadKey(); } else { break; } } operation.NewEmp(alias, name, surname, department, position); Console.WriteLine("Сотрудник успешно добавлен в базу данных."); //} //else //{ // Console.WriteLine("Сотрудник с такими паспортными данными уже существует!"); //} Console.ReadKey(); break; case "delete": while (true) { Console.Clear(); Console.WriteLine("Введите псевдоним сотрудника, которого вы хотите удалить"); alias = Console.ReadLine(); if (operation.Employees.Exists(x => x.Alias == alias)) { operation.Delete(alias); Console.WriteLine("Сотрудник был успешно удален с базы данных"); Console.ReadKey(); break; } else { Console.WriteLine("Сотрудника с таким псевдонимом не найдено."); Console.ReadKey(); break; } } break; case "all": Console.Clear(); Console.WriteLine(draw.MakeTableResults(operation.Employees)); Console.ReadKey(); break; case "find": Console.Clear(); Console.WriteLine("Введите псевдоним сотрудника, которого вы хотите найти"); alias = Console.ReadLine(); if (operation.Employees.Exists(x => x.Alias == alias)) { operation.Delete(alias); Console.WriteLine(operation.FindEmployee(alias).ToString()); Console.ReadKey(); break; } else { Console.WriteLine("Сотрудника с таким псевдонимом не найдено."); Console.ReadKey(); break; } case "exit": if (read.ReadLine() == "XML") { Log = new LogXml(); } if (read.ReadLine() == "BIN") { Log = new LogBinary(); } Log.LogSave(operation.Employees); return; } if (command.ToLower() != "add" && command.ToLower() != "delete" && command.ToLower() != "all" && command.ToLower() != "find" && command.ToLower() != "exit") { Help(); } } }
public Game(IUserInterface userInterface, IWriteFile writeFile, IReadFile readFile) { this._userInterface = userInterface; this._writeFile = writeFile; this._readFile = readFile; }
public ColorMixing(IReadFile ReadFile) { readFile = ReadFile; }
public SyncFiles(IReadFile readFile, IHandleData handleData) { this.readFile = readFile; this.handleData = handleData; this.handleData.unitOfWork = unitOfWork; }
public FileController(DataProviderWrapperService dataProviderService, ILoggerFactory loggerFactory) { this.writeFileService = dataProviderService; this.readFileService = dataProviderService; this.logger = loggerFactory.CreateLogger <FileController>(); }
public CallBack(Game game, IWriteFile writeFile, IReadFile readFile) { this._game = game; this._writeFile = writeFile; this._readFile = readFile; }
// this forces modifying AddressFileProcessor, though it was specifically required not to // I opted this way since it just felt natural to abstract away and inject the resultant // interfaces into constructor (though probably will break "production code" ) while // testing also becomes easier public CSVReaderWriter(IOpenFile fileOpener, IReadFile fileReader, IWriteFile fileWriter) { _fileOpener = fileOpener; _fileReader = fileReader; _fileWriter = fileWriter; }
public CsvParser(IReadFile readFile) { File = readFile ?? throw new ArgumentNullException(nameof(readFile)); }
public BaseExcel(IExcelService excelService) { importExcelService = excelService.Import(); exportExcelService = excelService.Export(); readFileService = excelService.ReadFile(""); }
public ImageResizeService(DataProviderWrapperService dataProviderService) { this.readFileService = dataProviderService; }