Beispiel #1
0
        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
Beispiel #2
0
        public static StateLogEntry BiserDecode(byte[] enc = null, Biser.Decoder extDecoder = null) //!!!!!!!!!!!!!! change return type
        {
            Biser.Decoder decoder = null;
            if (extDecoder == null)
            {
                if (enc == null || enc.Length == 0)
                {
                    return(null);
                }
                decoder = new Biser.Decoder(enc);
                if (decoder.CheckNull())
                {
                    return(null);
                }
            }
            else
            {
                if (extDecoder.CheckNull())
                {
                    return(null);
                }
                else
                {
                    decoder = extDecoder;
                }
                //decoder = new Biser.Decoder(extDecoder);
                //if (decoder.IsNull)
                //    return null;
            }

            StateLogEntry m = new StateLogEntry();  //!!!!!!!!!!!!!! change return type

            m.Term                 = decoder.GetULong();
            m.Index                = decoder.GetULong();
            m.Data                 = decoder.GetByteArray();
            m.IsCommitted          = decoder.GetBool();
            m.PreviousStateLogId   = decoder.GetULong();
            m.PreviousStateLogTerm = decoder.GetULong();
            m.RedirectId           = decoder.GetULong();

            return(m);
        }
Beispiel #3
0
        public static StateLogEntrySuggestion BiserDecode(byte[] enc = null, Biser.Decoder extDecoder = null) //!!!!!!!!!!!!!! change return type
        {
            Biser.Decoder decoder = null;
            if (extDecoder == null)
            {
                if (enc == null || enc.Length == 0)
                {
                    return(null);
                }
                decoder = new Biser.Decoder(enc);
                if (decoder.CheckNull())
                {
                    return(null);
                }
            }
            else
            {
                if (extDecoder.CheckNull())
                {
                    return(null);
                }
                else
                {
                    decoder = extDecoder;
                }
                //decoder = new Biser.Decoder(extDecoder);
                //if (decoder.IsNull)
                //    return null;
            }

            StateLogEntrySuggestion m = new StateLogEntrySuggestion();  //!!!!!!!!!!!!!! change return type

            m.LeaderTerm    = decoder.GetULong();
            m.StateLogEntry = StateLogEntry.BiserDecode(extDecoder: decoder);
            m.IsCommitted   = decoder.GetBool();

            return(m);
        }
Beispiel #4
0
        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