示例#1
0
        public string Serialize(object instance)
        {
            if (instance == null)
            {
                return(string.Empty);
            }

            switch (instance)
            {
            case MessageRaw m:
                var visitor = new VisitorJsonSerialiser();
                var tokens  = visitor.VisitMessageRaw(m);
                return(tokens.ToString(Formatting.None));

            case Workflow w:
                return(DynObjectSerializer.Serialize(w, typeof(Workflow)));

            case Event e:
                return(DynObjectSerializer.Serialize(e, typeof(Event)));

            case IncomingEvent i:
                return(DynObjectSerializer.Serialize(i, typeof(IncomingEvent)));

            default:
                return(TypeDiscovery.Instance.SerializeObject(instance));
            }
        }
示例#2
0
 public void DeserializeExtendedDatas(string payload, IExtendedDatas instance)
 {
     TypeDiscovery.Instance.PopulateObject(payload, instance);
     DynObjectSerializer.Deserialize(instance, payload);
 }