public static void LoadSettingData() { var list = FileInput.Input(FilePath); // ファイルの存在を確認する if (list != null) { // foreachを使いファイルをデータ化する foreach (string line in list) { var str = line.Split('\t'); switch (list.IndexOf(line)) { case 0: // 一行目 if (str.Length < 2) { goto write; // 書式が不正だったとき } double.TryParse(str[0], out SettingData.scale); byte.TryParse(str[1], out SettingData.fullscreen); break; } } return; } write: // 存在しなかった場合新しくファイルを出力する SettingData = new setting(0); WriteSettingData(SettingData, true); return; }
public Menu() { bool stopExecution = false; while (!stopExecution) { MenuItems item; ShowMenu(); item = (MenuItems)GetMenuItem(); IInput input; switch (item) { case MenuItems.CustomInput: input = new CustomInput(); break; case MenuItems.RandomInput: input = new RandomInput(); break; case MenuItems.FileInput: input = new FileInput(); break; case MenuItems.Exit: stopExecution = true; break; } } }
private void btnLoadFileInput_Click(object sender, EventArgs e) { btnLoadFileInput.Text = @"Loading..."; btnLoadFileInput.Enabled = false; txtFileInput.ReadOnly = true; FileInput.FilePath = txtFileInput.Text; var errorMessage = FileInput.LoadInputData(); if (errorMessage != "") { MessageBox.Show(errorMessage, @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { InitInputData(); InitDisplayInputData(); MessageBox.Show($@"Load data from file {txtFileInput.Text} successfully!", @"Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } btnLoadFileInput.Text = @"Load"; btnLoadFileInput.Enabled = true; txtFileInput.ReadOnly = false; }
public void MethodGetTest_TestFileEquationAdd_ListEquationExpected() { // Arrange string testString = "file.txt"; FileInput fileInput = new FileInput(testString); List <string> expected = new List <string>() { new string("15+(713-4+(3-2))/(5+(12.5+15.3)*2)+(18-4*2)+1*2"), new string("15+713-4+(3-2))/(5+(12.5+15.3)*2)+(18-4*2)+1*2"), new string("15/0"), new string("(2*2)+(3*3)-(15/3)"), new string("not equation"), new string("2+11-3"), new string("8.5*3-10"), new string("2+2*3"), new string("1+2*(3+2)"), new string("1+2+4"), new string("2+15/3+4*2"), new string("x-4"), new string("1-x"), new string("x+4"), new string("1+x"), new string("x*4"), new string("1*x"), new string("x/4"), new string("1/x"), new string("2+x-3"), new string("1+x+4") }; // Act List <string> actual = fileInput.Get(); // Assert CollectionAssert.AreEqual(expected, actual); }
public ActionResult AddFileToPost(PostAddress postAddress, FileInput fileInput, string returnUri) { Post post = postService.GetPost(postAddress); if (post == null) { return(null); } post.AddFile(fileInput); postService.EditPost(post); if (!string.IsNullOrEmpty(returnUri)) { return(new RedirectResult(returnUri)); } File newFile = post.GetFile(new FileAddress(fileInput.Url)); if (newFile != null) { return(PartialView("ManageFile", new OxiteModelItem <File> { Item = newFile, Container = post })); } return(new JsonResult { Data = false });; }
public void SendFileData(FileInput fileInput) { using (IProducer producer = factory.Open(postFileSetting)) { producer.Send(fileInput); } }
static void Main(string[] args) { ArrayList zoo = new ArrayList(); GatherInput inputGatherer = new GatherInput(zoo); inputGatherer.GetUserInput(); foreach (ITalkable thing in zoo) { Printout(thing); } outFile.FileClose(); inFile.FileRead(); inFile.FileClose(); FileInput indata = new FileInput("animals.txt"); string line; while ((line = indata.FileReadLine()) != null) { Console.WriteLine(line); } }
public static string Read(string path) { StringReader reader; try { reader = new StringReader(FileInput.Invoke(path)); } catch (Exception e) { Print("File open failed.\n"); Print("At file: " + path + "\n\n"); return(null); } string str = ""; try { while (reader.Peek() != -1) { str = str + (reader.ReadLine() + "\n"); } reader.Dispose(); } catch (Exception e) { Print("File read error.\n"); Print("At file: " + path + "\n\n"); return(null); } return(str); }
public void Log_ReadMGPLogsFromFileInput() { var input = new FileInput("MGP_TestLog1.log"); var log = new Log("GameWarrior", new Log4NetLogParser(), input); Assert.AreEqual(13, log.EntriesCount); }
private static int Main(string[] args) { _cliArgs = new CliArgs(); if (!CommandLineParser.ParseArguments(args, _cliArgs)) { string usage = CommandLineParser.ArgumentsUsage(typeof(CliArgs)); Console.WriteLine(usage); return(5); } IStatementReader statementInput = new ConsoleInput(_cliArgs.Hostname); if (null != _cliArgs.File) { statementInput = new FileInput(_cliArgs.File); } CommandContext.DebugLog = _cliArgs.DebugLog; try { var statementReader = new StatementSplitter(statementInput); Run(statementReader); } catch (Exception ex) { Console.WriteLine("Failed with error {0}", ex); return(5); } return(0); }
static void StartUp() { Console.WriteLine("Choose Options"); Console.WriteLine("1. Standard Input 2. Input from FILE"); var selection = Console.ReadLine(); switch (selection) { case "1": var standardInput = new StandardInput( SetupTurtle(), (message) => Console.WriteLine(message), () => Helpers.ClearCommandLine(), (command) => command.IsValidPlaceCommand()); standardInput.Execute(); break; case "2": var fileInput = new FileInput( SetupTurtle(), (message) => Console.WriteLine(message), () => { }, (command) => command.IsValidPlaceCommand()); fileInput.Execute(); break; default: BackToStartUp(); break; } }
public Response <int> AddFileToDocument([FromBody] FileInput fileInput) { return(GetResponse <int>(() => { return new DataService(User).AddFile(fileInput); })); }
public void RemoveWhiteSpaceTest() { FileInput Test = new FileInput(""); string TestString = Test.RemoveWhiteSpace("a b c"); Assert.AreEqual(TestString, "abc", "White space not removed!"); }
public async Task <ActionResult <FileData> > ConvertFile([FromForm] FileInput file) { if (!ModelState.IsValid) { return(BadRequest(ModelState.Keys.First())); } var list = new List <string>(); using (var stream = file.File.OpenReadStream()) { using (var reader = new StreamReader(stream)) { while (reader.Peek() >= 0) { list.Add(await reader.ReadLineAsync()); } } } var fileData = _fileReaderProvider.ConvertFile(file.File.FileName, list.ToArray()); if (fileData.HasErrors()) { return(BadRequest(fileData.Error)); } return(Ok(fileData)); }
/// <summary> /// Vérifie les informations et retourne les éventuelles erreurs à afficher /// </summary> /// <returns></returns> private async Task <string> Validate() { var retour = ""; if (Password == null || (Password != null && Password.Length < 8)) { retour += ResourceLoader.GetForCurrentView("Errors").GetString("erreurNb8Caracteres") + "\r\n"; } if (FileInput == null) { retour += ResourceLoader.GetForCurrentView("Errors").GetString("erreurAucunFichierEntre") + "\r\n"; } else { var toto = (await FileInput.GetBasicPropertiesAsync()).Size; if ((await FileInput.GetBasicPropertiesAsync()).Size > ContexteStatic.MaxSizeFichierChiffrer) { retour += ResourceLoader.GetForCurrentView("Errors").GetString("erreurFichierEntreGros") + "\r\n"; } } if (FileOutput == null) { retour += ResourceLoader.GetForCurrentView("Errors").GetString("erreurAucunFichierSorti") + "\r\n"; } return(retour); }
private void New_Click(object sender, EventArgs e) { //differentiates between new being clicked and load being clicked when saving a file New.IsAccessible = true; Random.IsAccessible = false; //show the option to create a file and reset everything File.Visible = true; dataGridView1.Visible = false; FileInput.Clear(); //clears previous filename for a new filename to be entered //sets dimensions of display Output.Size = new System.Drawing.Size(521, 105); Output.Location = new System.Drawing.Point(12, 240); FileContents.Location = new System.Drawing.Point(11, 225); File.Location = new System.Drawing.Point(150, 94); //old Format (Save for future use): ///if (fileName != null && fileName.Length > 9) //if filename is bigger than 9 ///{ //format the display ///Output.Size = new System.Drawing.Size(244, 83); ///Output.Location = new System.Drawing.Point(12, 255); ///FileContents.Location = new System.Drawing.Point(14, 225); ///} ///else ///{ //format the display /// Output.Size = new System.Drawing.Size(244, 101); ////Output.Location = new System.Drawing.Point(12, 237); ///FileContents.Location = new System.Drawing.Point(14, 223); ///} }
public void RenderTest() { FileInput target = new FileInput(); Assert.AreEqual("<input type=\"file\" name=\"test\" />", target.Render("test", null)); Assert.AreEqual("<input type=\"file\" name=\"test\" />", target.Render("test", "test1")); }
private void Random_Click(object sender, EventArgs e) { //show the option to create a file and reset everything File.Visible = true; dataGridView1.Visible = false; New.IsAccessible = false; Random.IsAccessible = true; FileInput.Clear(); //changes display Output.Size = new System.Drawing.Size(521, 105); Output.Location = new System.Drawing.Point(12, 240); FileContents.Location = new System.Drawing.Point(11, 225); File.Location = new System.Drawing.Point(150, 94); //old Format (Save for future use): ///if (fileName != null && fileName.Length > 9) //if filename is bigger than 9 ///{ //format the display ///Output.Size = new System.Drawing.Size(244, 83); ///Output.Location = new System.Drawing.Point(12, 255); ///FileContents.Location = new System.Drawing.Point(14, 225); ///} ///else ///{ //format the display /// Output.Size = new System.Drawing.Size(244, 101); ////Output.Location = new System.Drawing.Point(12, 237); ///FileContents.Location = new System.Drawing.Point(14, 223); ///} }
private FileInput GetInputData(ReceiveData receiveData) { FileInput input = receiveData.GetObject <FileInput>(); getDataInputConsumer.SetAcknowledge(receiveData.DeliveryTag, true); return(input); }
public override bool Execute() { BooCompiler compiler = new BooCompiler(); if (OutputAssembly == null) { compiler.Parameters.Pipeline = new CompileToMemory(); } else { compiler.Parameters.Pipeline = new CompileToFile(); compiler.Parameters.OutputAssembly = OutputAssembly.ItemSpec; } compiler.Parameters.OutputType = CompilerOutputType.ConsoleApplication; if (files == null || files.Length == 0) { Log.LogError("Must specify at least one file for the book task"); return false; } foreach (ITaskItem taskItem in files) { FileInput input = new FileInput(taskItem.ItemSpec); compiler.Parameters.Input.Add(input); } foreach (ITaskItem reference in references) { Assembly assembly = Assembly.LoadFrom(reference.ItemSpec); compiler.Parameters.References.Add(assembly); } CompilerContext run = compiler.Run(); if (run.Errors.Count > 0) { string s = run.Errors.ToString(true); Log.LogError("Failed to compile code: " + s); return false; } MethodInfo methodInfo = run.GeneratedAssembly.EntryPoint; if (methodInfo == null) { Log.LogError("Could not find entry point for the files"); return false; } try { methodInfo.Invoke(null, new object[] { new string[0] }); } catch (TargetInvocationException e) { Log.LogError("Scripts failed to run!"); Log.LogError(e.InnerException.ToString()); } return true; }
public ModelResult <File> EditFile(Post post, File fileToEdit, FileInput fileInput) { File file = repository.Save(post.ID, new File(fileToEdit.ID, fileInput.TypeName, fileInput.MimeType, new Uri(fileInput.Url), fileInput.SizeInBytes)); //TODO: (erikpo) Invalidate caching return(new ModelResult <File>(file, null)); }
public void readFromfile() { FileInput Test = new FileInput("./file_input_test.txt"); string[] ans = Test.ReadFromFile(); string[] rightans = { "p2=>p3", "p3=>p1", "p1=>d", "p1&p3=>c", "~a", "b", "p2", "as", "a&v", "h|~gl", "5g&sd<=>t", "d=>s" }; CollectionAssert.AreEqual(ans, rightans); }
public ModelResult <File> AddFile(ScheduleItem scheduleItem, FileInput fileInput) { File file = repository.Save(scheduleItem.ID, new File(Guid.Empty, fileInput.TypeName, fileInput.MimeType, new Uri(fileInput.Url), fileInput.SizeInBytes)); //TODO: (erikpo) Invalidate caching return(new ModelResult <File>(file, null)); }
/// <summary> /// Encrypts or decrypts text using the current Enigma machine. /// </summary> public void StartCipher() { Debug.LogMethodStart(); string type; FileInput inputFile; if (IsDecrypting) { type = "Decrypt"; } else { type = "Encrypt"; } ConsoleOutput.IndentWriteLine($"Now starting {type.ToLower()}ion with Enigma Machine: {Current.Name}"); ConsoleOutput.ContinuePrompt(); string toCipher = ""; switch (InputType) { case InputType.html: inputFile = new FileInput(FileIn + ".html"); toCipher = Utility.HtmlToText(inputFile.Read()); break; case InputType.txt: inputFile = new FileInput(FileIn + ".txt"); toCipher = inputFile.Read(); break; case InputType.keyboard: toCipher = UserInput.GetStringFromUser($"Enter text to be {type.ToLower()}ed"); inputFile = null; break; default: InputType = InputType.keyboard; inputFile = null; StartCipher(); break; } if (toCipher?.Length > 0) { Debug.Log(false, $"INPUT:\n {toCipher}"); var outputFile = new FileOutput(FileOut); var builder = new StringBuilder(); string output = Cipher(toCipher.ToCharArray(), inputFile); builder.Append(Utility.TextToHtml(output, $"{type}ion output from Enigma Machine: {Current.Name}")); outputFile.Write(builder, ($"Wrote {type.ToLower()}ed output to file {outputFile.Path}.")); ConsoleOutput.IndentWriteLine($"{type}ion complete. Resetting {Current.Name}'s rotors to initial settings."); } else { ConsoleOutput.IndentWriteLine($"Error: could not find anything to {type.ToLower()}"); } ConsoleOutput.ContinuePrompt(); }
public void AddToEndTest() { FileInput Test = new FileInput(""); string[] TestArray1 = "a b".Split(' '); string[] TestArray2 = Test.AddToEnd(TestArray1, "c"); Assert.AreEqual(TestArray2.Length, 3); Assert.AreEqual(TestArray2[2], "c"); }
public void ReadFileMissingFileReturnsException() { var calcFileInput = new FileInput(); var result = calcFileInput.ReadFile(@"C:\foo\bar\nofile.txt"); Assert.True(result.HasException); Assert.Equal(@"File Path references non existent file", result.Exception); }
public void ReadFileMissingFileNameReturnsException() { var calcFileInput = new FileInput(); var result = calcFileInput.ReadFile(string.Empty); Assert.True(result.HasException); Assert.Equal(@"No file path value supplied", result.Exception); }
public void FileInputToPaserToWorld() { FileInput input = new FileInput("./t1.txt"); Model temp = new Model(); PropositionInterpreter test = new PropositionInterpreter(ref temp); Proposition[] temper = test.ParseProps(input.ReadFromFile()); World MyWorld = new World(temper, temp.Length); }
public void BackwardChainAndImp() { FileInput input = new FileInput("./t2.txt"); Model temp = new Model(); PropositionInterpreter test = new PropositionInterpreter(ref temp); World MyWorld = new World(test.ParseProps(input.ReadFromFile()), temp.Length); BackwardsChain solver = new BackwardsChain(temp, MyWorld); solver.Start(); }
public FileOutput ConvertToFileOutput(FileInput input, RoutingIndexManager manager, RoutingModel routing, Assignment solution) { return(new FileOutput() { DroppedLocation = GetDroppedLocations(input, manager, routing, solution), Itineraries = GetItineraries(input, manager, routing, solution), Summaries = GetSummaries(input, manager, routing, solution), Totals = GetTotals(input, manager, routing, solution) }); }
/// <summary> /// 切片目录 /// </summary> /// <param name="input"></param> /// <returns></returns> private string GetTempPath(FileInput input) { var path = Path.Combine(_appConfig.FilePath, TEMP_FOLDER, input.Guid); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } return(path); }
static void ShowFileInfo(ButtonIcon bt, Div log, FileInput input) { log.Empty (); bt.Disabled = input.Files.Length == 0; foreach (var f in input.Files) { log.Append ("Name:{0}<br>Size:{1}<br>Type:{2}<br>LastModifiedDate:{3}<br>" .Fmt(f.Name,f.Size,f.Type,f.LastModifiedDate.ToString("dd-MM-yyyy HH:mm:ss"))); } }
void Start() { button_style.normal.background = button_up_texture; button_style.active.background = button_down_texture; button_style.normal.textColor = Color.white; button_style.active.textColor = new Color(0.75f,0.75f,0.75f); button_style.alignment = TextAnchor.MiddleCenter; button_style.fontSize = 30; input = new EclipseInput("UnideeJavaCode",Application.dataPath + "/Vendor/Unidee/Examples/UnideeJavaCode/Example.java"); }
static void SendFile(ButtonIcon bt, FileInput input) { bt.Disabled = true; var fd = new FormData (); fd.Append ("userfile", input.Files [0]); var rq = fd.Send ("SaveFileUrl"); rq.Done (() => "File Uploaded".LogSuccess (5000)); rq.Fail (()=> "{0}:{1}".Fmt(rq.Status, rq.StatusText).LogError()); rq.Always (() => bt.Disabled=false); }
public void Append(string key, FileInput value, string name) { }
public UnpicklerObject(Stream file) : this() { _file = new FileInput(file); }
private void RefactorTest(string newName, string caretText, FileInput[] inputs, params ExpectedPreviewItem[] items) { RefactorTest(newName, caretText, inputs, true, null, items); }
private void RefactorTest(string newName, string caretText, FileInput[] inputs, bool mutateTest = true, Version version = null, params ExpectedPreviewItem[] items) { for (int i = 0; i < inputs.Length; ++i) { Console.WriteLine("Test code {0} {1}:\r\n{2}\r\n", i, inputs[i].Filename, inputs[i].Input); } foreach(bool preview in new[] { true, false } ) { OneRefactorTest(newName, caretText, inputs, version, preview, null, items); if (mutateTest) { // try again w/ a longer name MutateTest(newName, caretText, inputs, version, newName + newName, preview); // and a shorter name MutateTest(newName, caretText, inputs, version, new string(newName[0], 1), preview); } } }
private void OneRefactorTest(string newName, string caretText, FileInput[] inputs, Version version, bool preview, string error, ExpectedPreviewItem[] expected = null) { Console.WriteLine("Replacing {0} with {1}", caretText, newName); version = version ?? new Version(2, 7); for (int loops = 0; loops < 2; loops++) { var views = new List<PythonEditor>(); try { var mainView = new PythonEditor(inputs[0].Input, version.ToLanguageVersion(), _vs, filename: inputs[0].Filename); var analyzer = mainView.Analyzer; views.Add(mainView); var bufferTable = new Dictionary<string, ITextBuffer> { { inputs[0].Filename, mainView.CurrentSnapshot.TextBuffer } }; foreach (var i in inputs.Skip(1)) { var editor = new PythonEditor(i.Input, version.ToLanguageVersion(), _vs, mainView.Factory, analyzer, i.Filename); views.Add(editor); bufferTable[i.Filename] = editor.CurrentSnapshot.TextBuffer; } // test runs twice, one w/ original buffer, once w/ re-analyzed buffers. if (loops == 1) { // do it again w/ a changed buffer mainView.Text = mainView.Text; } var caretPos = inputs[0].Input.IndexOf(caretText); mainView.View.MoveCaret(new SnapshotPoint(mainView.CurrentSnapshot, caretPos)); var extractInput = new RenameVariableTestInput(newName, bufferTable, preview); var previewChangesService = new TestPreviewChanges(expected); new VariableRenamer(views[0].View.View, _vs.ServiceProvider).RenameVariable(extractInput, previewChangesService); if (error != null) { Assert.AreEqual(error, extractInput.Failure); return; } Assert.IsNull(extractInput.Failure, "Unexpected error message: " + (extractInput.Failure ?? "")); Assert.AreEqual(preview, previewChangesService.Previewed, preview ? "Changes were not previewed" : "Changes were previewed"); AssertUtil.ArrayEquals(inputs.Select(i => i.Output).ToList(), views.Select(v => v.Text).ToList()); } finally { views.Reverse(); foreach (var v in views) { v.Dispose(); } } } }
private void MutateTest(string newName, string caretText, FileInput[] inputs, Version version, string altNewName, bool preview) { FileInput[] moreInputs = new FileInput[inputs.Length]; for (int i = 0; i < moreInputs.Length; i++) { moreInputs[i] = new FileInput( inputs[i].Input, inputs[i].Output.Replace(newName, altNewName), inputs[i].Filename ); } OneRefactorTest(altNewName, caretText, moreInputs, version, preview, null); }