public static T FromJsonResource <T>(string path, bool replaceText = false) where T : class { string source = Heluo.Game.Resource.LoadString(path); if (replaceText && string.IsNullOrEmpty(source)) { // filename replace source = Heluo.Game.Resource.LoadString(GlobalLib.ReplaceText(source)); } if (string.IsNullOrEmpty(source)) { Console.WriteLine("找不到Json资源: " + path); return(null); } if (source[0] != '{') { // original load from FileHelperEngine var fileHelperEngine = new FileHelpers.FileHelperEngine <T>(System.Text.Encoding.UTF8); return(fileHelperEngine.ReadString(source)[0]); } else { // load from valid json if (replaceText) { // content replace source = GlobalLib.ReplaceText(source); } return(FromJsonMod <T>(source)); } }
public static Dictionary <string, Moto> Get() { Moto[] list; var assembly = typeof(Moto).GetTypeInfo().Assembly; var engine = new FileHelpers.FileHelperEngine <Moto>(); using (var stream = assembly.GetManifestResourceStream("MotoDetector.Data.motos.csv")) { using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8)) { list = engine.ReadStream(reader); } } return(list.ToDictionary(x => x.ID)); }
public static Dictionary <string, ResNet50Feature> Get() { ResNet50Feature[] list; var assembly = typeof(ResNet50Feature).GetTypeInfo().Assembly; var engine = new FileHelpers.FileHelperEngine <ResNet50Feature>(); using (var stream = assembly.GetManifestResourceStream("MotoDetector.Data.features.csv")) { using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8)) { list = engine.ReadStream(reader); } } return(list.ToDictionary(x => x.ID.ToLower())); }
/// <summary> /// A helper method that extracts the data from the CSV flat files /// and populates a simple local object model of Members and /// their respective Expensive for programmatic access and logic /// </summary> /// <param name="members">The enumerable of members that /// will be populated by this method</param> public static void PrepDataModel(ref IList<IMember> members) { FileHelperEngine<ExpenseMapping> engine = new FileHelpers.FileHelperEngine<ExpenseMapping>(); engine.ErrorManager.ErrorMode = ErrorMode.IgnoreAndContinue; IEnumerable<ExpenseMapping> flatExpenses = engine.ReadFile(EXPENSE_FILE_LOCATION); foreach (ExpenseMapping flatExpense in flatExpenses) { if (members.Count(m => m.Name == flatExpense.MemberName) == 0) { //not got this member in the list yet, add them first members.Add(new Member() { Name = flatExpense.MemberName, Constituency = flatExpense.MemberConstituency, TwitterHandle = FindTwitterHandle(flatExpense.MemberName), FacebookHandle = FindFacebookHandle(flatExpense.MemberName) }); } IMember currentMember = members.First(m => m.Name == flatExpense.MemberName); currentMember.Expenses.Add(new Expense(currentMember) { Date = flatExpense.Date, ClaimNumber = flatExpense.ClaimNumber, Type = flatExpense.Type, Category = flatExpense.Category, Description = flatExpense.Description, Detail = flatExpense.Details, Status = flatExpense.Status, AmountClaimed = flatExpense.AmountClaimed, AmountPaid = flatExpense.AmountPaid, AmountNotPaid = flatExpense.AmountNotPaid, AmountRepaid = flatExpense.AmountRepaid }); } }
public CSVParser() { engine = new FileHelpers.FileHelperEngine <CSVCourse>(); }
public CSVParser(String theFilePath) { engine = new FileHelpers.FileHelperEngine <CSVCourse>(); filePath = theFilePath; records = engine.ReadFile(theFilePath); }