public string Serialize(object value) { if (this.IsFormated == false) { TypeConverter typeConverter = TypeDescriptor.GetConverter(typeof(DateTime)); return(typeConverter.ConvertToString(value)); } string serializedValue = "·"; TupleIndexer tupleIndexer = new TupleIndexer(value); int counter = 1; if (this.HasYear) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasMonth) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasDay) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasHour) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasMinute) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasSecond) { serializedValue += tupleIndexer[counter++]; } return(serializedValue); }
public DateTime GetDateTime(object value) { if (this.IsFormated == false) { return((DateTime)value); } int year = 2000, month = 1, day = 1, hour = 0, minute = 0, second = 0; TupleIndexer tupleIndexer = new TupleIndexer(value); int counter = 1; if (this.HasYear) { year = tupleIndexer[counter++]; } if (this.HasMonth) { month = tupleIndexer[counter++]; } if (this.HasDay) { day = tupleIndexer[counter++]; } if (this.HasHour) { hour = tupleIndexer[counter++]; } if (this.HasMinute) { minute = tupleIndexer[counter++]; } if (this.HasSecond) { second = tupleIndexer[counter++]; } return(new DateTime(year, month, day, hour, minute, second)); }
public DateTime GetDateTime(object value) { if (this.IsFormated == false) { return (DateTime)value; } int year = 2000, month = 1, day = 1, hour = 0, minute = 0, second = 0; TupleIndexer tupleIndexer = new TupleIndexer(value); int counter = 1; if (this.HasYear) year = tupleIndexer[counter++]; if (this.HasMonth) month = tupleIndexer[counter++]; if (this.HasDay) day = tupleIndexer[counter++]; if (this.HasHour) hour = tupleIndexer[counter++]; if (this.HasMinute) minute = tupleIndexer[counter++]; if (this.HasSecond) second = tupleIndexer[counter++]; return new DateTime(year, month, day, hour, minute, second); }
public string Serialize(object value) { if (this.IsFormated == false) { TypeConverter typeConverter = TypeDescriptor.GetConverter(typeof(DateTime)); return typeConverter.ConvertToString(value); } string serializedValue = "·"; TupleIndexer tupleIndexer = new TupleIndexer(value); int counter = 1; if (this.HasYear) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasMonth) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasDay) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasHour) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasMinute) { serializedValue += tupleIndexer[counter++]; } serializedValue += ","; if (this.HasSecond) { serializedValue += tupleIndexer[counter++]; } return serializedValue; }