public static NodeSettings BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } NodeSettings m = new NodeSettings(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "RaftEntitiesSettings": m.RaftEntitiesSettings = decoder.CheckNull() ? null : new List <RaftEntitySettings>(); if (m.RaftEntitiesSettings != null) { foreach (var el in decoder.GetList()) { m.RaftEntitiesSettings.Add(RaftEntitySettings.BiserJsonDecode(null, decoder)); } } break; case "TcpClusterEndPoints": m.TcpClusterEndPoints = decoder.CheckNull() ? null : new List <TcpClusterEndPoint>(); if (m.TcpClusterEndPoints != null) { foreach (var el in decoder.GetList()) { m.TcpClusterEndPoints.Add(TcpClusterEndPoint.BiserJsonDecode(null, decoder)); } } break; default: decoder.SkipValue(); //MUST BE HERE break; } } return(m); } //eof
public static StateLogEntrySuggestion BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } StateLogEntrySuggestion m = new StateLogEntrySuggestion(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "LeaderTerm": m.LeaderTerm = decoder.GetULong(); break; case "StateLogEntry": m.StateLogEntry = StateLogEntry.BiserJsonDecode(null, decoder); break; case "IsCommitted": m.IsCommitted = decoder.GetBool(); break; default: decoder.SkipValue(); //Must be here break; } } return(m); }//eof
public static TS3 BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } TS3 m = new TS3(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "P1": m.P1 = decoder.GetString(); break; case "P2": m.P2 = decoder.GetInt_NULL(); break; case "P3": m.P3 = decoder.GetDateTime(); break; default: decoder.SkipValue(); //Must be here break; } } return(m); }//eof
public static TcpClusterEndPoint BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } TcpClusterEndPoint m = new TcpClusterEndPoint(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "Host": m.Host = decoder.GetString(); break; case "Port": m.Port = decoder.GetInt(); break; default: decoder.SkipValue(); //MUST BE HERE break; } } return(m); }//eof
public static TS7 BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { decoder = extDecoder; } TS7 m = new TS7(); foreach (var props in decoder.GetDictionary <string>()) { switch (props.ToLower()) { case "votetype": m.VoteType = (eVoteType)decoder.GetShort(); break; case "barabaka": m.Barabaka = decoder.GetInt(); break; default: decoder.SkipValue(); break; } } return(m); }
public static RaftEntitySettings BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } RaftEntitySettings m = new RaftEntitySettings(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "EntityName": m.EntityName = decoder.GetString(); break; //case "LeaderHeartbeatMs": // m.LeaderHeartbeatMs = decoder.GetUInt(); // break; case "DelayedPersistenceMs": m.DelayedPersistenceMs = decoder.GetUInt(); break; //case "NoLeaderAddCommandResendIntervalMs": // m.NoLeaderAddCommandResendIntervalMs = decoder.GetUInt(); // break; case "DelayedPersistenceIsActive": m.DelayedPersistenceIsActive = decoder.GetBool(); break; case "InMemoryEntity": m.InMemoryEntity = decoder.GetBool(); break; case "InMemoryEntityStartSyncFromLatestEntity": m.InMemoryEntityStartSyncFromLatestEntity = decoder.GetBool(); break; //case "ElectionTimeoutMinMs": // m.ElectionTimeoutMinMs = decoder.GetInt(); // break; //case "ElectionTimeoutMaxMs": // m.ElectionTimeoutMaxMs = decoder.GetInt(); // break; //case "LeaderLogResendIntervalMs": // m.LeaderLogResendIntervalMs = decoder.GetUInt(); // break; //case "RaftNodeIdExternalForEmulator": // m.RaftNodeIdExternalForEmulator = decoder.GetInt(); // break; //case "InitialQuantityOfRaftNodesInTheCluster": // m.InitialQuantityOfRaftNodesInTheCluster = decoder.GetUInt(); // break; case "VerboseRaft": m.VerboseRaft = decoder.GetBool(); break; case "VerboseTransport": m.VerboseTransport = decoder.GetBool(); break; default: decoder.SkipValue(); //MUST BE HERE break; } } return(m); } //eof
public static StateLogEntry BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } StateLogEntry m = new StateLogEntry(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "Term": m.Term = decoder.GetULong(); break; case "Index": m.Index = decoder.GetULong(); break; case "Data": m.Data = decoder.GetByteArray(); break; case "IsCommitted": m.IsCommitted = decoder.GetBool(); break; case "PreviousStateLogId": m.PreviousStateLogId = decoder.GetULong(); break; case "PreviousStateLogTerm": m.PreviousStateLogTerm = decoder.GetULong(); break; case "RedirectId": m.RedirectId = decoder.GetULong(); break; default: decoder.SkipValue(); //Must be here break; } } return(m); }//eof
public static TS2 BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } TS2 m = new TS2(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "P1": m.P1 = decoder.GetLong(); break; case "P2": m.P2 = decoder.GetDouble(); break; case "P3": m.P3 = decoder.CheckNull() ? null : new List <TS3>(); if (m.P3 != null) { foreach (var el in decoder.GetList()) { m.P3.Add(TS3.BiserJsonDecode(null, decoder)); } } //decoder.GetCollection( // () => { return TS3.BiserJsonDecode(null, decoder); }, m.P3, true); break; case "P4": m.P4 = TS3.BiserJsonDecode(null, decoder); break; case "P5": m.P5 = decoder.GetUInt_NULL(); break; default: decoder.SkipValue(); //Must be here break; } } return(m); }//eof
public static TS1 BiserJsonDecode(string enc = null, Biser.JsonDecoder extDecoder = null, Biser.JsonSettings settings = null) //!!!!!!!!!!!!!! change return type { Biser.JsonDecoder decoder = null; if (extDecoder == null) { if (enc == null || String.IsNullOrEmpty(enc)) { return(null); } decoder = new Biser.JsonDecoder(enc, settings); if (decoder.CheckNull()) { return(null); } } else { //JSONSettings of the existing decoder will be used decoder = extDecoder; } TS1 m = new TS1(); //!!!!!!!!!!!!!! change return type foreach (var props in decoder.GetDictionary <string>()) { switch (props) { case "P1": m.P1 = decoder.GetInt(); break; case "P2": m.P2 = decoder.GetInt(); break; case "P3": m.P3 = decoder.GetDecimal(); break; case "P4": m.P4 = decoder.CheckNull() ? null : new List <TS2>(); if (m.P4 != null) { foreach (var el in decoder.GetList()) { m.P4.Add(TS2.BiserJsonDecode(null, decoder)); } } break; case "P5": m.P5 = decoder.CheckNull() ? null : new Dictionary <long, TS3>(); if (m.P5 != null) { foreach (var el in decoder.GetDictionary <long>()) { m.P5.Add(el, TS3.BiserJsonDecode(null, decoder)); } } break; case "P6": m.P6 = decoder.CheckNull() ? null : new Dictionary <uint, List <TS3> >(); if (m.P6 != null) { foreach (var el in decoder.GetDictionary <uint>()) { var lst = decoder.CheckNull() ? null : new List <TS3>(); if (lst != null) { foreach (var el1 in decoder.GetList()) { lst.Add(TS3.BiserJsonDecode(null, decoder)); } } m.P6.Add(el, lst); } } break; case "P7": m.P7 = TS2.BiserJsonDecode(null, decoder); break; case "P8": m.P8 = decoder.CheckNull() ? null : new List <Tuple <string, byte[], TS3> >(); if (m.P8 != null) { Tuple <string, byte[], TS3> tpl = null; foreach (var el in decoder.GetList()) { //foreach (var el1 in decoder.GetList()) //Tuple was also represented as an array //{ // tpl = new Tuple<string, byte[], TS3>( // decoder.GetString(), // decoder.GetByteArray(), // TS3.BiserJsonDecode(null, decoder)); //}//must come to the end, no returns in the middle of iteration //Or Dictionary that is represented with Item1, item2, Item3 for compatibility with other systems string i1 = ""; byte[] i2 = null; TS3 i3 = null; foreach (var tupleProps in decoder.GetDictionary <string>()) { switch (tupleProps) { case "Item1": i1 = decoder.GetString(); break; case "Item2": i2 = decoder.GetByteArray(); break; case "Item3": i3 = TS3.BiserJsonDecode(null, decoder); break; default: decoder.SkipValue(); break; } } tpl = new Tuple <string, byte[], TS3>(i1, i2, i3); m.P8.Add(tpl); } } break; case "P9": if (decoder.CheckNull()) { m.P9 = null; } else { //foreach (var el in decoder.GetList()) //heterogenous array //{ // m.P9 = new Tuple<float, TS2, TS3, decimal?>(decoder.GetFloat(), // TS2.BiserJsonDecode(null, decoder), TS3.BiserJsonDecode(null, decoder), decoder.GetDecimal_NULL()); //} //Or Dictionary that is represented with Item1, item2, Item3, Item4 for compatibility with other systems float i1 = 0; TS2 i2 = null; TS3 i3 = null; decimal?i4 = null; foreach (var tupleProps in decoder.GetDictionary <string>()) { switch (tupleProps) { case "Item1": i1 = decoder.GetFloat(); break; case "Item2": i2 = TS2.BiserJsonDecode(null, decoder); break; case "Item3": i3 = TS3.BiserJsonDecode(null, decoder); break; case "Item4": i4 = decoder.GetDecimal_NULL(); break; default: decoder.SkipValue(); //must be here break; } } m.P9 = new Tuple <float, TS2, TS3, decimal?>(i1, i2, i3, i4); } break; case "P11": m.P11 = decoder.CheckNull() ? null : new Dictionary <int, int>(); if (m.P11 != null) { foreach (var el in decoder.GetDictionary <int>()) { m.P11.Add(el, decoder.GetInt()); } } break; case "P12": m.P12 = decoder.GetInt(); break; case "P13": m.P13 = decoder.CheckNull() ? null : new List <TS3>(); if (m.P13 != null) { foreach (var el in decoder.GetList()) { m.P13.Add(TS3.BiserJsonDecode(null, decoder)); } } break; case "P14": m.P14 = decoder.CheckNull() ? null : new Dictionary <int, int>(); if (m.P14 != null) { foreach (var el in decoder.GetDictionary <int>()) { m.P14.Add(el, decoder.GetInt()); } } break; case "P15": m.P15 = decoder.CheckNull() ? null : new List <List <TS3> >(); if (m.P15 != null) { foreach (var el in decoder.GetList()) { var lst = decoder.CheckNull() ? null : new List <TS3>(); if (lst != null) { foreach (var el1 in decoder.GetList()) { lst.Add(TS3.BiserJsonDecode(null, decoder)); } } m.P15.Add(lst); } } break; case "P16": m.P16 = decoder.CheckNull() ? null : new Dictionary <long, List <TS3> >(); if (m.P16 != null) { foreach (var el in decoder.GetDictionary <long>()) { var lst = decoder.CheckNull() ? null : new List <TS3>(); if (lst != null) { foreach (var el1 in decoder.GetList()) { lst.Add(TS3.BiserJsonDecode(null, decoder)); } } m.P16.Add(el, lst); } } break; case "P17": m.P17 = decoder.GetDateTime(); break; case "P18": m.P18 = decoder.CheckNull() ? null : new List <int>(); if (m.P18 != null) { foreach (var el in decoder.GetList()) { m.P18.Add(decoder.GetInt()); } } break; case "P19": if (decoder.CheckNull()) { m.P19 = null; } else { //When stored as List //foreach (var el in decoder.GetList()) //heterogenous array //{ // m.P19 = new Tuple<int, TS3>(decoder.GetInt(), TS3.BiserJsonDecode(null, decoder)); //} //Or Dictionary that is represented with Item1, item2, Item3 for compatibility with other systems int i1 = 0; TS3 i2 = null; foreach (var tupleProps in decoder.GetDictionary <string>()) { switch (tupleProps) { case "Item1": i1 = decoder.GetInt(); break; case "Item2": i2 = TS3.BiserJsonDecode(null, decoder); break; default: decoder.SkipValue(); break; } } m.P19 = new Tuple <int, TS3>(i1, i2); } break; default: decoder.SkipValue(); //must be here break; } } return(m); }