//Из объекта public Moment(DataType dataType, object ob, int nd = 0, ErrorCalc error = null) { DataType = dataType; Nd = nd; Error = error; switch (dataType) { case DataType.Real: Real = Convert.ToDouble(ob); break; case DataType.Boolean: Boolean = Convert.ToBoolean(ob); break; case DataType.Integer: Integer = Convert.ToInt32(ob); break; case DataType.String: String = Convert.ToString(ob); break; case DataType.Time: Date = Convert.ToDateTime(ob); break; } }
public Moment(DateTime date, ErrorCalc error = null, int nd = 0) { DataType = DataType.Time; Date = date; Error = error; Nd = nd; }
public Moment(DataType dataType, DateTime time, ErrorCalc error = null, int nd = 0) { DataType = dataType; Time = time; Error = error; Nd = nd; }
public Moment(int integer, ErrorCalc error = null, int nd = 0) { DataType = DataType.Integer; Integer = integer; Error = error; Nd = nd; }
public Moment(double real, ErrorCalc error = null, int nd = 0) { DataType = DataType.Real; Real = real; Error = error; Nd = nd; }
public Moment(bool boolean, ErrorCalc error = null, int nd = 0) { DataType = DataType.Boolean; Boolean = boolean; Error = error; Nd = nd; }
//Из строкового значения public Moment(DataType dataType, string s, int nd = 0, ErrorCalc error = null) { DataType = dataType; Nd = nd; Error = error; switch (dataType) { case DataType.String: String = s; break; case DataType.Real: Real = s.ToDouble(); if (Double.IsNaN(Real)) { Real = 0; } break; case DataType.Time: DateTime t; Date = DateTime.TryParse(s, out t) ? t : Different.MinDate; break; case DataType.Integer: int i; Integer = Int32.TryParse(s, out i) ? i : 0; break; case DataType.Boolean: Boolean = s == "1"; break; } }
public Moment(string s, ErrorCalc error = null, int nd = 0) { DataType = DataType.String; String = s; Error = error; Nd = nd; }
public Moment(DateTime time, bool boolean, ErrorCalc error = null, int nd = 0) { DataType = DataType.Boolean; Time = time; Nd = nd; Error = error; Boolean = boolean; }
public Moment(DateTime time, string s, ErrorCalc error = null, int nd = 0) { DataType = DataType.String; Time = time; String = s; Error = error; Nd = nd; }
public Moment(DateTime time, double real, ErrorCalc error = null, int nd = 0) { DataType = DataType.Real; Time = time; Real = real; Error = error; Nd = nd; }
public Moment(DateTime time, int integer, ErrorCalc error = null, int nd = 0) { DataType = DataType.Integer; Time = time; Integer = integer; Error = error; Nd = nd; }
public Segment(DateTime begin, DateTime end, double pos, int nd = 0, ErrorCalc err = null) : base(begin, end) { Pos = pos; if (pos == -1) { IsResultTime = false; ResultTime = Begin; } else { IsResultTime = true; ResultTime = Begin.AddSeconds(end.Subtract(Begin).TotalSeconds *pos); } Nd = nd; Error = err; }
//Из действительного значения public Moment(DataType dataType, double d, int nd = 0, ErrorCalc error = null) { DataType = dataType; Nd = nd; Error = error; switch (dataType) { case DataType.String: String = d.ToString(); break; case DataType.Real: Real = d; break; case DataType.Integer: Integer = Convert.ToInt32(d); break; case DataType.Boolean: Boolean = d > 0; break; } }
public Moment(DataType dataType, object ob, DateTime time, int nd = 0, ErrorCalc error = null) : this(dataType, ob, nd, error) { Time = time; }
public Moment(DataType dataType = DataType.Value, ErrorCalc error = null, int nd = 0) { DataType = dataType; Error = error; Nd = nd; }
public Moment(DataType dataType, double d, DateTime time, int nd = 0, ErrorCalc error = null) : this(dataType, d, nd, error) { Time = time; }
public Moment(DataType dataType, string s, DateTime time, int nd = 0, ErrorCalc error = null) : this(dataType, s, nd, error) { Time = time; }