Serialize() public method

public Serialize ( ) : string
return string
Example #1
0
 /// <summary>
 /// Serialize this to exception to json as defined in Mycroft.Msg.MsgGeneralFailure.Serialize
 /// </summary>
 /// <returns>The JSON</returns>
 public string Serialize()
 {
     var msgFail = new Msg.MsgGeneralFailure();
     msgFail.Message = Message;
     msgFail.Received = Received;
     return msgFail.Serialize();
 }
 public void TestMsgGeneralFailureSerialization()
 {
     string target = "{\"received\":\"APP_MANFST {}\",\"message\":\"this is a message\"}";
     var msg = new MsgGeneralFailure();
     msg.Received = "APP_MANFST {}";
     msg.Message = "this is a message";
     string json = msg.Serialize();
     Assert.AreEqual(target, json);
 }
Example #3
0
 /// <summary>
 /// Check if this guid is already in the message archive
 /// If the GUID given already exists in the archive the app instance
 /// is notified and HasValidGuid is set to false
 /// </summary>
 /// <param name="messageArchive">The archive to visit</param>
 public override void VisitMessageArchive(MessageArchive messageArchive)
 {
     if (messageArchive[this.guid] != null)
     {
         HasValidGuid = false;
         var genFail = new MsgGeneralFailure();
         genFail.Received = "";
         genFail.Message = "The guid " + this.guid + " was already taken";
         var msg = "MSG_GENERAL_FAILURE " + genFail.Serialize();
         FromInstance.Send(msg);
     }
     else
         HasValidGuid = true;
 }
Example #4
0
        public override void VisitMessageArchive(MessageArchive messageArchive)
        {
            if (!messageArchive.TryPostMessage(this))
            {
                Debug.WriteLine("failed because message currently exists");
                var fail = new MsgGeneralFailure();
                fail.Message = "Message key '" + guid + "' currently exists in message archive, can't override";
                fail.FromInstanceId = FromInstance.InstanceId;
                fail.Received = "";

                FromInstance.Send("MSG_GENERAL_FAILURE " + fail.Serialize());

            }
        }