public void Example() { var others = new OtherData[] { new OtherData(), new OtherData() }; var data = new ExampleData(); data.otherData = others; data.otherExample = new ExampleData(); data.otherExample.otherData = others; data.otherExample.otherExample = data; string blob = BlobSerializer.Serialize(data); Debug.Log("Blob:\n" + blob); ExampleData deserializedData; if (BlobSerializer.Deserialize <ExampleData>(blob).TryGet(out deserializedData)) { Debug.LogFormat("integer = {0}", deserializedData.integer); Debug.LogFormat("number = {0}", deserializedData.number); Debug.LogFormat("boolean = {0}", deserializedData.boolean); Debug.LogFormat("text = {0}", deserializedData.text); Debug.LogFormat("abc = {0}", deserializedData.abc.ToStringFull()); Debug.LogFormat("other = {0}", deserializedData.otherData.ToStringFull()); Debug.LogFormat("OHTER integer = {0}", deserializedData.otherExample.integer); Debug.LogFormat("OHTER number = {0}", deserializedData.otherExample.number); Debug.LogFormat("OHTER boolean = {0}", deserializedData.otherExample.boolean); Debug.LogFormat("OHTER text = {0}", deserializedData.otherExample.text); Debug.LogFormat("OHTER abc = {0}", deserializedData.otherExample.abc.ToStringFull()); Debug.LogFormat("OHTER other = {0}", deserializedData.otherExample.otherData.ToStringFull()); } }
public void Save(Guid sagaId, ISagaEntity saga) { _data[sagaId] = new ProfileSagaEntity { SagaEntity = BlobSerializer.Serialize(saga), ProfileName = _pluginContext.ProfileName }; }
/// <summary> /// Sets the given key and value in the current session. Value is serialized using given /// custom serializer. /// </summary> /// <typeparam name="T">The type of the value.</typeparam> /// <param name="session">The session.</param> /// <param name="serializer">The custom serializer.</param> /// <param name="key">The key.</param> /// <param name="value">The value.</param> public static void SetObject <T>(this ISession session, ISerializer serializer, string key, T value) { using (var serializedStream = new PooledMemoryStream()) { BlobSerializer.Serialize(serializer, serializedStream, value); session.Set(key, serializedStream.ToArray()); } }
public void BlobSerializerTest() { var res = BlobSerializer.Serialize(new TestSagaData { TestValue = "testValue" }); res.Should(Be.Not.Null); var des = BlobSerializer.Deserialize(res, typeof(ISagaEntity).Name); des.Should(Be.Not.Null); des.Should(Be.TypeOf <TestSagaData>()); ((TestSagaData)des).TestValue.Should(Be.EqualTo("testValue")); }
public void EnsureJsonBlobSerializerVersion2WillNotBeChanged() { const string expected = @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema""> <Type>Tp.Integration.Plugin.Common.Tests.Common.SagaPersister.TestSagaData, Tp.Integration.Plugin.Common.Tests</Type> <Version>2</Version> <string>{""__type"":""TestSagaData:#Tp.Integration.Plugin.Common.Tests.Common.SagaPersister"",""Id"":""00000000-0000-0000-0000-000000000000"",""OriginalMessageId"":null,""Originator"":null,""TestValue"":""Value""}</string> </Value>" ; var expectedXml = XDocument.Parse(expected); var result = BlobSerializer.Serialize(new TestSagaData { TestValue = "Value" }); result.ToString().Should(Be.EqualTo(expectedXml.ToString())); JsonBlobSerializer.VERSION.Should(Be.EqualTo("2")); }
private void UpdateBlob() { ValueBlob = BlobSerializer.Serialize(GetValue()); }
public PostponedMessage(IMessage message) { _serializedMsg = BlobSerializer.Serialize(message); _type = message.GetType(); }