Serialize() public méthode

public Serialize ( ) : string
Résultat string
Exemple #1
0
        public Broadcast(String rawData, AppInstance instance)
        {
            var dp = (MsgBroadcast)MsgBroadcast.Deserialize(rawData);
            guid = dp.Id;
            msgContent = dp.Content;

            var bcast = new MsgBroadcast();
            bcast.FromInstanceId = instance.InstanceId;
            bcast.Id = guid;
            bcast.Content = msgContent;

            msg = verb + ' ' + bcast.Serialize();

            this.FromInstance = instance;
            sendto = new List<AppInstance>();
        }
        public void TestMsgBroadcastSerialization()
        {
            var msgBroadcast = new MsgBroadcast();
            msgBroadcast.Id = "uuid";
            var dct = new Dictionary<string, object>();
            dct.Add("text", "pickle unicorn");
            var innerDct = new Dictionary<string, object>();
            innerDct.Add("other", "blah");
            dct.Add("thing", innerDct);
            msgBroadcast.Content = dct;

            string json = msgBroadcast.Serialize();
            System.Diagnostics.Debug.WriteLine(json);

            Assert.IsTrue(json.IndexOf("\"other\":\"blah\"") > 0, "should have inner dict content");
        }