private Stream tgt = null; // new MemoryStream(); public PerfSer() { this.Ctzs = TimeZoneService.S.GetTimeZones(); this.core = new CsnSer(); this.forCore = new CsnForSer(); this.jcore = new JsonSer(Performance.JsonSer.longNames); }
static void WriteSer(ISerializer ser, String path, CsnTimeZones ctzs) { FileStream fs = new FileStream(path, FileMode.Create); StreamWriter sw = new StreamWriter(fs, Encoding.UTF8); ser.Serialize(ctzs, sw); sw.Flush(); sw.Close(); }
public void Serialize(CsnTimeZones ctzs, StreamWriter sw) { //JsonSerializer json = new JsonSerializer(); //json.Serialize(sw, ctzs); JsonTextWriter json = new JsonTextWriter(sw); Serialize(ctzs, json); json.Flush(); }
private void Serialize(CsnTimeZones ctzs, JsonTextWriter json) { json.WriteStartObject(); json.WritePropertyName(this.names[0]); json.WriteStartArray(); foreach (CsnTimeZone ctz in ctzs.AllTimeZones) { Serialize(ctz, json); } json.WriteEndArray(); json.WriteEndObject(); }
public CsnTimeZones GetTimeZones() { CsnTimeZones tzs = new CsnTimeZones(); tzs.AllTimeZones = TimeZoneInfo.GetSystemTimeZones().Select(x => new CsnTimeZone(x)).ToArray(); List <CsnTimeZone> newList = new List <CsnTimeZone>(); for (int i = 0; i < 1; i++) { newList.AddRange(tzs.AllTimeZones); } tzs.AllTimeZones = newList.ToArray(); return(tzs); }
public void Serialize(CsnTimeZones ctzs, StreamWriter sw) { Writer w = new Writer(sw); // typedefs long ttType = w.WriteTypeDef("TransitionTime", "IsFixedDateRule", "Day", "Month", "TimeOfDay", "Week", "DayOfWeek").Current; long adjType = w.WriteTypeDef("Adjustment", "StartDate", "EndDate", "DaylightDeltaHours", "TransitionStart", "TransitionEnd").Current; long tzType = w.WriteTypeDef("TimeZone", "Id", "DisplayName", "DaylightName", "StandardName", "HasDst", "UtcOffsetHours", "Adjustments").Current; long tzsType = w.WriteTypeDef("TimeZones", "AllTimeZones").Current; var rcTzs = ctzs.AllTimeZones.Select(x => WriteTz(x, w, tzType, adjType, ttType)); long rc = w.WriteArray().WRef(rcTzs.ToArray()).Current; w.WriteInstance(tzsType).WRef(rc); sw.Flush(); }
public void Serialize(CsnTimeZones ctzs, StreamWriter sw) { Writer w = new Writer(sw); // typedefs long ttType = w.WriteTypeDef("TransitionTime", "IsFixedDateRule", "Day", "Month", "TimeOfDay", "Week", "DayOfWeek").Current; long adjType = w.WriteTypeDef("Adjustment", "StartDate", "EndDate", "DaylightDeltaHours", "TransitionStart", "TransitionEnd").Current; long tzType = w.WriteTypeDef("TimeZone", "Id", "DisplayName", "DaylightName", "StandardName", "HasDst", "UtcOffsetHours", "Adjustments").Current; long tzsType = w.WriteTypeDef("TimeZones", "AllTimeZones").Current; int tzLen = ctzs.AllTimeZones.Length; long?[] rcTzsArr = new long?[tzLen]; for (int tzCtr = 0; tzCtr < tzLen; tzCtr++) { CsnTimeZone ctz = ctzs.AllTimeZones[tzCtr]; long? rcAdjArr = null; if (ctz.Adjustments != null) { int adjLen = ctz.Adjustments.Length; if (adjLen > 0) { long?[] arrAdjs = new long?[adjLen]; for (int adjCtr = 0; adjCtr < adjLen; adjCtr++) { CsnAdjustment adj = ctz.Adjustments[adjCtr]; long? rcTtStart = this.WriteTrTime(adj.TransitionStart, w, ttType); long? rcTtEnd = this.WriteTrTime(adj.TransitionEnd, w, ttType); arrAdjs[adjCtr] = w.WriteInstance(adjType).W(adj.StartDate).W(adj.EndDate).W(adj.DaylightDeltaHours).WRef(rcTtStart).WRef(rcTtEnd).Current; } rcAdjArr = w.WriteArray().WRef(arrAdjs).Current; } } rcTzsArr[tzCtr] = w.WriteInstance(tzType).W(ctz.Id).W(ctz.DisplayName).W(ctz.DaylightName).W(ctz.StandardName).W(ctz.HasDst).W(ctz.UtcOffsetHours).WRef(rcAdjArr).Current; } long rc = w.WriteArray().WRef(rcTzsArr).Current; w.WriteInstance(tzsType).WRef(rc); sw.Flush(); }
public void Serialize(CsnTimeZones ctzs, StreamWriter sw) { JsonSerializer json = new JsonSerializer(); json.Serialize(sw, ctzs); }