internal LogEntryViewModel(LogEntry logEntry) { Entry = logEntry; Timestamp = TimestampPattern.Format(logEntry.Timestamp.InZone(TimeZone).LocalDateTime); Text = Entry.Exception is null ? Entry.Message : $"{Entry.Message}: {Entry.Exception.GetType()}; {Entry.Exception.Message}"; ToolTip = Entry.Exception is null ? null : Entry.Exception.StackTrace; }
public static void Save(string csvPath, TimeSeries series) { var fullPath = Path.Combine(csvPath, $"{series.Name}.csv"); var lines = new List <string>(); if (!File.Exists(fullPath)) { lines.Add("date,open,high,low,close,volume"); } for (var i = 0; i < series.TickCount; i++) { var tick = series.GetTick(i); lines.Add( $"{DateTimePattern.Format(tick.EndTime)},{tick.OpenPrice},{tick.MaxPrice},{tick.MinPrice},{tick.ClosePrice},{tick.Volume}"); } if (!Directory.Exists(csvPath)) { // TODO: logging Directory.CreateDirectory(csvPath); } File.AppendAllLines(fullPath, lines); }
/// <summary> /// Constructor /// Sets up the default serialization for some basic types, which can /// be overwritten by the user. /// </summary> public TypeConverterSetup() { /* * Default type conversions */ this.RegisterTypeConverter <int, string>(x => x.ToString()); this.RegisterTypeConverter <string, int>(x => Convert.ToInt32(x)); this.RegisterTypeConverter <long, string>(x => x.ToString()); this.RegisterTypeConverter <string, long>(x => Convert.ToInt64(x)); this.RegisterTypeConverter <float, string>(x => x.ToString()); this.RegisterTypeConverter <string, float>(x => Convert.ToSingle(x)); this.RegisterTypeConverter <double, string>(x => x.ToString()); this.RegisterTypeConverter <string, double>(x => Convert.ToDouble(x)); this.RegisterTypeConverter <decimal, string>(x => x.ToString()); this.RegisterTypeConverter <string, decimal>(x => Convert.ToDecimal(x)); this.RegisterTypeConverter <LocalDate, string>(x => datePattern.Format(x)); this.RegisterTypeConverter <string, LocalDate>(x => datePattern.Parse(x).Value); this.RegisterTypeConverter <LocalDateTime, string>((x) => { return(dtPattern.Format(x)); }); this.RegisterTypeConverter <string, LocalDateTime>((x) => { return(dtPattern.Parse(x).Value); }); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { if (destinationType == typeof(string)) { return(_pattern.Format((LocalDateTime)value)); } if (destinationType == typeof(DateTime)) { return(((LocalDateTime)value).ToDateTimeUnspecified()); } return(base.ConvertTo(context, culture, value, destinationType)); }
protected override void OnConfiguring(TypeConverterSetup typeConverterSetup, Configurator configurator) { typeConverterSetup .RegisterTypeConverter <LocalDateTime, string>((x) => { return(pattern.Format(x)); }) .RegisterTypeConverter <string, LocalDateTime>((x) => { return(pattern.Parse(x).Value); }); configurator .SetTransactionParallelism(1) .SetQueryParallelism(1) .EnableDurability(false); }
public static string LocalDateTime(LocalDateTime value) => LocalDateTimePattern.Format(value);
public void FormatWithNumbersToSecond() { PatternWithNumbersToSecond.Format(SampleLocalDateTime); }
internal string _toUrlParam(LocalDateTime start, LocalDateTime end) { return($"{_localDateTimePattern.Format(start)}/{_localDateTimePattern.Format(end)}"); }
/// <summary> /// Formats a local date/time for XML. /// </summary> /// <param name="dateTime">The date to format to XML</param> /// <returns>The date formatted to XML</returns> internal static string XmlFromLocalDateTime(LocalDateTime dateTime) { return(XmlLocalDateTimePattern.Format(dateTime)); }
protected string _toUrlParam(LocalDateTime dateTime) { return(_localDateTimePattern.Format(dateTime)); }
public static string FormatFileName(LocalDateTime date) { return(DatePattern.Format(date)); }