public static void RegisterJsonSerializer(this MyDataFlowBase serializer)
        {
            serializer.RegisterSerializerDeserializer(
                o =>
            {
                var list     = new List <byte>();
                var type     = o.GetType();
                var typeName = type.ToString();
                RegisterTypeIfNotExists(typeName, type);

                list.AddRange(Encoding.ASCII.GetBytes(typeName));
                list.Add(DataSeparator);
                list.AddRange(Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(o)));
                return(list.ToArray());
            },
                bytes =>
            {
                var(typeName, data) = bytes.GetTypeNameAndData();

                if (TryGetJsonType(typeName, out var type))
                {
                    return(Newtonsoft.Json.JsonConvert.DeserializeObject(data, type));
                }

                throw new Exception("Invalid DataFlow type: " + type);
            });
        }
示例#2
0
 public StartFlowHelper(MyDataFlowBase myDataFlowBase)
 {
     _myDataFlowBase = myDataFlowBase;
 }