static void Main(string[] args) { var engine = new FileHelperEngine <Person>(); var people = engine.ReadFileAsList("./Input/People.csv"); using (var client = new RequestSocket(">tcp://127.0.0.1:5556")) { var serializer = StrategySerializer.GetSerializer <Person>(SerializerType.JSON); people.ForEach((person) => { // client sends message consisting of two frames var serializedItem = serializer.Serialize(person); Console.WriteLine("Client sending..."); client.SendFrame(serializedItem); // client receives signal if (client.ReceiveSignal()) { Console.WriteLine("Received OK Signal, message was received."); } else { Console.WriteLine("Received ERROR Signal, message was not received."); } }); Console.ReadKey(true); } }
public static IList <MappingEntryCsv> ReadFile(FileHelperEngine <MappingEntryCsv> engine, string fullPathFileName) { if (engine == null || File.Exists(fullPathFileName) == false || Path.GetExtension(fullPathFileName) != FileExtension) { return(null); } return(engine.ReadFileAsList(fullPathFileName)); }
public static List<ChequeInfo> GetFileChequeList(string path) { var engine = new FileHelperEngine<ChequeInfoFile>(); engine.Options.IgnoreFirstLines = 1; var sampleList = engine.ReadFileAsList(path); var convertedList = ConvertChequeListFromFile(sampleList); return convertedList; }
// GET: Users/Parse public ActionResult Parse() { var engine = new FileHelperEngine<User>(); List<User> result = engine.ReadFileAsList("C:/TIY/Projects/Week-4-Day-3/Week4.Day3/Week4.Day3/Files/users.txt"); StringBuilder lines = new StringBuilder(); lines.AppendLine("First Name, Last Name, e-mail address"); foreach (User u in result) { lines.AppendLine(u.FirstName + ", " + u.LastName + ", " + u.Email); } Session["CSVFilePackage"] = lines; return View(result); }
public List <Part> Read() { return(engine.ReadFileAsList(filePath)); }
static void Main(string[] args) { var engine = new FileHelperEngine <Game>(); // Instatiate the FileHelper engine to read/write the CSV file // Get the directory and file name then import it into a list string currentDirectory = Directory.GetCurrentDirectory(); DirectoryInfo directory = new DirectoryInfo(currentDirectory); var fileName = Path.Combine(directory.FullName, "vgsales.csv"); engine.ErrorManager.ErrorMode = ErrorMode.SaveAndContinue; // Set the engine object to ignore errors and continue parsing Console.WriteLine("Importing previous session data...."); List <Game> salesResults = engine.ReadFileAsList(fileName); while (true) // Main program loop. Goes through menu until the user quits { Console.WriteLine("What what you like to do"); Console.WriteLine("Type in 1 to add a Title"); Console.WriteLine("Type in 2 to delete a Title"); Console.WriteLine("Type in 3 to list top 10 games"); Console.WriteLine("Type in 4 to quit"); var answer = Console.ReadLine(); if (answer == "1") { Console.Clear(); salesResults.Add(AddList()); // Adds the object that was created in the AddList method Console.Clear(); } if (answer == "2") { Console.Clear(); int removeInput = RemoveGame(salesResults); // This variable is used to actually REMOVE the item from the list if (removeInput == -1) // This is used when the user cancels out of remove function { Console.Clear(); Console.WriteLine("Selection canceled"); Console.WriteLine(""); } else { salesResults.RemoveAt(removeInput); Console.Clear(); Console.WriteLine("Selection removed"); Console.WriteLine(""); } } else if (answer == "3") { salesResults[0].SortList(salesResults); } else if (answer == "4") // Quits out of the while loop { break; } else { Console.WriteLine("Please enter in a valid option"); } } // Takes what ever data is left in the "salesResults" variable and writes it back to the file Console.WriteLine("Writing data to file and exiting"); engine.WriteFile("vgsales.csv", salesResults); Console.WriteLine("Finished saving file. Hit any key to quit."); Console.ReadLine(); }