public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { double output; bool done = double.TryParse(text, System.Globalization.NumberStyles.Number, CultureInfo.CurrentCulture, out output); return(output); }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { text = text.Replace("(", ""); text = text.Replace(")", ""); text = text.Replace("?", ""); int y = Int32.Parse(text); return(new DateTime(y, 1, 1)); }
public override string ConvertToString(CsvHelper.TypeConversion.TypeConverterOptions options, object value) { T result; if (Enum.TryParse <T>(value.ToString(), out result)) { return((Convert.ToInt32(result)).ToString()); } return(base.ConvertToString(options, value)); //throw new InvalidCastException(String.Format("Invalid value to EnumConverter. Type: {0} Value: {1}", typeof (T), value)); }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { if (text.Equals("")) { return((long)0); } else { return(Int64.Parse(text)); } }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { if (text.Equals("Parlator") || text.Equals("Informator") || text.Equals("Eksplorator")) { return(Enum.Parse(typeof(SpeakerType), text)); } else { return(SpeakerType.Eksplorator); } }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { switch (text) { case "miasto": return(PlaceType.town); case "wieś": return(PlaceType.village); default: return(PlaceType.noInformation); } }
public string ConvertToString(CsvHelper.TypeConversion.TypeConverterOptions options, object value) { DateTime val = (DateTime)value; double res = 0; res += val.Hour / 24; res += val.Minute / (24 * 60); res += val.Second / (24 * 60 * 60); return(res.ToString()); }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { double val = Double.Parse(text); int h = (int)(val * 24); val -= ((h / 24) - 1); int m = (int)(val * 24 * 60); val -= m / (24 * 60); int s = (int)(val * 24 * 60 * 60); return((double)(s + (60 * m) + (60 * 60 * h))); }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { switch (text) { case "matka z tej samej miejscowości": return(ParentsOrigin.motherFromTheSamePlace); case "oboje z innej miejscowości lub tylko ojciec z tej samej": return(ParentsOrigin.bothFromDifferentPlaceOrOnlyFatherFromTheSame); case "oboje z tej samej miejscowości": return(ParentsOrigin.bothFromTheSamePlace); default: return(ParentsOrigin.noInformation); } }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { switch (text) { case "całe życie": return(DwellingTime.wholeLife); case "całe życie.": return(DwellingTime.wholeLife); case "część życia": return(DwellingTime.partOfLife); default: return(DwellingTime.noInformation); } }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { switch (text) { case "wyższe": return(Education.higher); case "średnie": return(Education.secondary); case "zawodowe": return(Education.vocational); case "gimnazjalne": return(Education.middle); case "podstawowe": return(Education.primary); default: return(Education.noInformation); } }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { if (text.Equals("brak informacji")) { return(Age.noInformation); } int age = Int16.Parse(text); if (age >= 60) { return(Age.old); } else if (age >= 30) { return(Age.middleAged); } else { return(Age.young); } }
public string ConvertToString(CsvHelper.TypeConversion.TypeConverterOptions options, object value) { return(value.ToString()); }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { return(Int64.Parse(text)); }
public string ConvertToString(CsvHelper.TypeConversion.TypeConverterOptions options, object value) { return((bool)value ? "" : "(?)"); }
public object ConvertFromString(CsvHelper.TypeConversion.TypeConverterOptions options, string text) { return((text.IndexOf("?") == -1) ? false : true); }