Ejemplo n.º 1
0
        public static LightJson.JsonValue LJ_Value(this CMD_Base cmd_base)
        {
            if (cmd_base is AC_Req)
            {
                return((cmd_base as AC_Req).LJ_Value());                       // don't fully understand the sorcery behind this - there is an implicit cast operator for JsonObject -> JsonValue
            }
            if (cmd_base is AC_Resp)
            {
                return((cmd_base as AC_Resp).LJ_Value());
            }

            if (cmd_base is EVAL_Req)
            {
                return((cmd_base as EVAL_Req).LJ_Value());
            }
            if (cmd_base is EVAL_Resp)
            {
                return((cmd_base as EVAL_Resp).LJ_Value());
            }

            if (cmd_base is TYPEINFO_Resp)
            {
                return((cmd_base as TYPEINFO_Resp).LJ_Value());
            }
            throw new NotImplementedException();
        }
Ejemplo n.º 2
0
 public void Write(CMD_Base cmd, bool debug = true)
 {
     if (debug)                                            // use intermediate StringStream to Debug Dump before sending to network
     {
         StringWriter strWR           = new StringWriter();
         var          dummy_LJ_Writer = new LightJson.Serialization.JsonWriter(strWR);
         WriteInternal(cmd, dummy_LJ_Writer);
         streamWriter.Write(strWR.ToString().NLSend("WROTE| "));
     }
     else
     {
         WriteInternal(cmd, LJ_Writer);
     }
     streamWriter.Flush();    // TODO guesswork , i want immediate genereation of TCP packet at this point. MSDN is pretty obtuse in this regard
 }
Ejemplo n.º 3
0
 public static LightJson.JsonObject addTypeTag(LightJson.JsonObject jObj, CMD_Base cmd_base)
 {
     return(jObj.Add("cmd", cmd_base.GetType().Name));
 }
Ejemplo n.º 4
0
 public void WriteInternal(CMD_Base cmd_base, LightJson.Serialization.JsonWriter LJ_Writer)         // with explicit stream adapter for convenient unit tesing
 {
     LJ_Writer.Write(cmd_base.LJ_Value());
 }