public static void DebugToConsole(this CommandObject cmd)
        {
            Console.WriteLine("-------Schema----------");

            for (int x = 0; x < cmd.Schema.NodeCount; x++)
            {
                Console.WriteLine(cmd.Schema[x]);
            }

            Console.WriteLine("-------Data----------");


            var rdr3 = cmd.ToCommand().MakeDataReader();

            while (!rdr3.IsEmpty)
            {
                Console.WriteLine(rdr3.Read());
            }

            Console.WriteLine("-------Reader----------");
            var rdr = cmd.ToCommand().MakeReader();

            Console.WriteLine(rdr.ToString());
            while (rdr.Read())
            {
                Console.WriteLine(rdr.ToString());
            }
            Console.WriteLine(rdr.ToString());

            Console.WriteLine("-------Text----------");

            Console.WriteLine(cmd.ToString());
        }
 public ManualResetEventSlim Send(CommandObject command)
 {
     if (!command.Schema.ProcessRuntimeID.HasValue)
     {
         return(Send(PacketMethods.CreatePacket(PacketContents.CommandSchemaWithData, 0, command.ToCommand().ToArray())));
     }
     else
     {
         int schemeRuntimeID;
         lock (m_knownSchemas)
         {
             if (!m_knownSchemas.TryGetValue(command.Schema.ProcessRuntimeID.Value, out schemeRuntimeID))
             {
                 if (command.Schema.ProcessRuntimeID == -1)
                 {
                     throw new Exception("Cannot serialize a schema that has not been defined in this process.");
                 }
                 schemeRuntimeID = m_knownSchemas.Count;
                 m_knownSchemas.Add(command.Schema.ProcessRuntimeID.Value, schemeRuntimeID);
                 Send(command.Schema.ToCommand(schemeRuntimeID));
             }
         }
         return(Send(command.ToDataCommandPacket(schemeRuntimeID)));
     }
 }