예제 #1
0
        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());
            }
        }
예제 #2
0
 /// <summary>
 ///   Retrieves the value of the given key, if present. Value is deserialized 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>
 /// <returns>An optional cache result which contains result value, if any.</returns>
 public static CacheResult <T> GetObject <T>(this ISession session, ISerializer serializer, string key)
 {
     if (session.TryGetValue(key, out var serializedBytes))
     {
         using (var serializedStream = new PooledMemoryStream(serializedBytes))
         {
             return(BlobSerializer.Deserialize <T>(serializer, serializedStream));
         }
     }
     return(default(CacheResult <T>));
 }
예제 #3
0
        public void DeserializeAfterAddingDataMember()
        {
            var s = @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Integration.Common.UserDTO, Tp.Integration.Messages</Type>
  <Version>2</Version>
  <string>{""__type"":""UserDTO:#Tp.Integration.Common"",""&lt;ID&gt;k__BackingField"":null,""&lt;ActiveDirectoryName&gt;k__BackingField"":null,""&lt;AvailableFrom&gt;k__BackingField"":null,""&lt;AvailableFutureAllocation&gt;k__BackingField"":0,""&lt;AvailableFutureHours&gt;k__BackingField"":0.0000,""&lt;CreateDate&gt;k__BackingField"":""\/Date(1361685600000+0300)\/"",""&lt;CurrentAllocation&gt;k__BackingField"":100,""&lt;CurrentAvailableHours&gt;k__BackingField"":0.0000,""&lt;DefaultRoleName&gt;k__BackingField"":""Support Person"",""&lt;DeleteDate&gt;k__BackingField"":null,""&lt;Email&gt;k__BackingField"":""*****@*****.**"",""&lt;FirstName&gt;k__BackingField"":""Tod"",""&lt;IsActive&gt;k__BackingField"":false,""&lt;IsAdministrator&gt;k__BackingField"":false,""&lt;IsObserver&gt;k__BackingField"":false,""&lt;LastName&gt;k__BackingField"":""Black"",""&lt;Login&gt;k__BackingField"":""*****@*****.**"",""&lt;ModifyDate&gt;k__BackingField"":""\/Date(1361685600000+0300)\/"",""&lt;Password&gt;k__BackingField"":""1846175709"",""&lt;RoleID&gt;k__BackingField"":6,""&lt;Skills&gt;k__BackingField"":null,""&lt;UserID&gt;k__BackingField"":4,""&lt;WeeklyAvailableHours&gt;k__BackingField"":40.0000}</string>
</Value>";

            var user = BlobSerializer.Deserialize(XDocument.Parse(s), "Tp.Integration.Common.UserDTO, Tp.Integration.Messages") as UserDTO;

            user.UserID.Should(Be.EqualTo(4));
        }
예제 #4
0
        public void DeserializeAfterCustomFieldsModifications()
        {
            var s = @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Integration.Common.ProjectDTO, Tp.Integration.Messages</Type>
  <Version>2</Version>
  <string>{""__type"":""ProjectDTO:#Tp.Integration.Common"",""ID"":13,""Abbreviation"":""TPW"",""CompanyID"":null,""CreateDate"":""\/Date(1372312800000+0300)\/"",""CustomField1"":null,""CustomField10"":null,""CustomField11"":null,""CustomField12"":null,""CustomField13"":null,""CustomField14"":null,""CustomField15"":null,""CustomField16"":null,""CustomField17"":null,""CustomField18"":null,""CustomField19"":null,""CustomField2"":null,""CustomField20"":null,""CustomField21"":null,""CustomField22"":null,""CustomField23"":null,""CustomField24"":null,""CustomField25"":null,""CustomField26"":null,""CustomField27"":null,""CustomField28"":null,""CustomField29"":null,""CustomField3"":null,""CustomField30"":null,""CustomField31"":null,""CustomField32"":null,""CustomField33"":null,""CustomField34"":null,""CustomField35"":null,""CustomField36"":null,""CustomField37"":null,""CustomField38"":null,""CustomField39"":null,""CustomField4"":null,""CustomField40"":null,""CustomField41"":null,""CustomField42"":null,""CustomField43"":null,""CustomField44"":null,""CustomField45"":null,""CustomField46"":null,""CustomField47"":null,""CustomField48"":null,""CustomField49"":null,""CustomField5"":null,""CustomField50"":null,""CustomField51"":null,""CustomField52"":null,""CustomField53"":null,""CustomField54"":null,""CustomField55"":null,""CustomField56"":null,""CustomField57"":null,""CustomField58"":null,""CustomField59"":null,""CustomField6"":null,""CustomField60"":null,""CustomField7"":null,""CustomField8"":null,""CustomField9"":null,""CustomFieldsMetaInfo"":[{""&lt;EntityFieldName&gt;k__BackingField"":""CustomField1"",""&lt;FieldType&gt;k__BackingField"":6,""&lt;Items&gt;k__BackingField"":[],""&lt;Name&gt;k__BackingField"":""cfnumber"",""&lt;Required&gt;k__BackingField"":false,""&lt;Value&gt;k__BackingField"":null}],""DeleteDate"":null,""Description"":null,""EndDate"":null,""EntityTypeName"":""Tp.BusinessObjects.Project"",""InboundMailAutoCheck"":false,""InboundMailAutomaticalEmailCheckTime"":0,""InboundMailCreateRequests"":false,""InboundMailLogin"":null,""InboundMailPassword"":null,""InboundMailPort"":110,""InboundMailProtocol"":null,""InboundMailReplyAddress"":null,""InboundMailServer"":null,""InboundMailUseSSL"":false,""IsActive"":true,""IsInboundMailEnabled"":false,""IsProduct"":false,""LastCommentDate"":null,""LastCommentUserID"":null,""LastEditorID"":2,""ModifyDate"":""\/Date(1372312800000+0300)\/"",""Name"":""Tau Product Web Site - Scrum #1"",""NumericPriority"":2,""OwnerID"":2,""ParentProjectID"":null,""ParentProjectName"":null,""ProcessID"":3,""ProcessName"":""Scrum"",""ProgramOfProjectID"":1,""ProgramOfProjectName"":""tauLine #1"",""ProjectID"":13,""SCConnectionString"":null,""SCPassword"":null,""SCStartingRevision"":null,""SCUser"":null,""SourceControlType"":0,""StartDate"":""\/Date(1372312800000+0300)\/""}</string>
</Value>";

            var project = BlobSerializer.Deserialize(XDocument.Parse(s), "Tp.Integration.Common.ProjectDTO, Tp.Integration.Messages") as ProjectDTO;

            project.ProjectID.Should(Be.EqualTo(13));
        }
예제 #5
0
        public void DeserializeGeneralProjectChangedSagaDataAfterAddingFields()
        {
            const string oldSaga = @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Search.Bus.Workflow.GeneralProjectChangeSagaData, Tp.Search</Type>
  <Version>2</Version>
  <string>{""__type"":""GeneralProjectChangeSagaData:#Tp.Search.Bus.Workflow"",""CommentsCurrentDataWindowSize"":0,""CommentsRetrievedCount"":0,""GeneralId"":147,""Id"":""534a26de-645c-4e66-9f83-a43b0152e933"",""OriginalMessageId"":""9753de6d-3e2d-4d1b-9b60-8d449f5592cc\\3914349"",""Originator"":""Tp.Search@D-KANASHEVICH"",""ProjectId"":13}</string>
</Value>";

            var deserialized = (GeneralProjectChangeSagaData)BlobSerializer.Deserialize(XDocument.Parse(oldSaga), string.Empty);

            deserialized.ProjectId.Should(Be.EqualTo(13));
            deserialized.TestStepsRetrievedCount.Should(Be.EqualTo(0));
        }
예제 #6
0
        public void DeserializeAfterAdding60CustomFields()
        {
            const string s = @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Integration.Common.ProjectDTO, Tp.Integration.Messages</Type>
  <Version>2</Version>
  <string>{""__type"":""ProjectDTO:#Tp.Integration.Common"",""&lt;ID&gt;k__BackingField"":null,""&lt;Abbreviation&gt;k__BackingField"":""TPW"",""&lt;CompanyID&gt;k__BackingField"":null,""&lt;CreateDate&gt;k__BackingField"":""\/Date(1360821600000+0300)\/"",""&lt;CustomField10&gt;k__BackingField"":null,""&lt;CustomField11&gt;k__BackingField"":null,""&lt;CustomField12&gt;k__BackingField"":null,""&lt;CustomField13&gt;k__BackingField"":null,""&lt;CustomField14&gt;k__BackingField"":null,""&lt;CustomField15&gt;k__BackingField"":null,""&lt;CustomField1&gt;k__BackingField"":null,""&lt;CustomField2&gt;k__BackingField"":null,""&lt;CustomField3&gt;k__BackingField"":null,""&lt;CustomField4&gt;k__BackingField"":null,""&lt;CustomField5&gt;k__BackingField"":null,""&lt;CustomField6&gt;k__BackingField"":null,""&lt;CustomField7&gt;k__BackingField"":null,""&lt;CustomField8&gt;k__BackingField"":null,""&lt;CustomField9&gt;k__BackingField"":null,""&lt;DeleteDate&gt;k__BackingField"":null,""&lt;Description&gt;k__BackingField"":null,""&lt;EndDate&gt;k__BackingField"":null,""&lt;EntityTypeName&gt;k__BackingField"":""Tp.BusinessObjects.Project"",""&lt;InboundMailAutoCheck&gt;k__BackingField"":false,""&lt;InboundMailAutomaticalEmailCheckTime&gt;k__BackingField"":0,""&lt;InboundMailCreateRequests&gt;k__BackingField"":false,""&lt;InboundMailLogin&gt;k__BackingField"":null,""&lt;InboundMailPassword&gt;k__BackingField"":null,""&lt;InboundMailPort&gt;k__BackingField"":110,""&lt;InboundMailProtocol&gt;k__BackingField"":null,""&lt;InboundMailReplyAddress&gt;k__BackingField"":null,""&lt;InboundMailServer&gt;k__BackingField"":null,""&lt;InboundMailUseSSL&gt;k__BackingField"":false,""&lt;IsActive&gt;k__BackingField"":true,""&lt;IsInboundMailEnabled&gt;k__BackingField"":false,""&lt;IsProduct&gt;k__BackingField"":false,""&lt;LastCommentDate&gt;k__BackingField"":null,""&lt;LastCommentUserID&gt;k__BackingField"":null,""&lt;LastEditorID&gt;k__BackingField"":1,""&lt;ModifyDate&gt;k__BackingField"":""\/Date(1365165112000+0300)\/"",""&lt;Name&gt;k__BackingField"":""Tau Product Web Site - Scrum #1"",""&lt;NumericPriority&gt;k__BackingField"":2,""&lt;OwnerID&gt;k__BackingField"":2,""&lt;ParentProjectID&gt;k__BackingField"":null,""&lt;ParentProjectName&gt;k__BackingField"":null,""&lt;ProcessID&gt;k__BackingField"":3,""&lt;ProcessName&gt;k__BackingField"":""Scrum"",""&lt;ProgramOfProjectID&gt;k__BackingField"":1,""&lt;ProgramOfProjectName&gt;k__BackingField"":""tauLine #1"",""&lt;ProjectID&gt;k__BackingField"":13,""&lt;SCConnectionString&gt;k__BackingField"":null,""&lt;SCPassword&gt;k__BackingField"":null,""&lt;SCStartingRevision&gt;k__BackingField"":null,""&lt;SCUser&gt;k__BackingField"":null,""&lt;SourceControlType&gt;k__BackingField"":0,""&lt;StartDate&gt;k__BackingField"":""\/Date(1360821600000+0300)\/""}</string>
</Value>";

            var project = BlobSerializer.Deserialize(XDocument.Parse(s), "Tp.Integration.Common.ProjectDTO, Tp.Integration.Messages") as ProjectDTO;

            project.ID.Should(Be.EqualTo(13));
            project.CustomFieldsMetaInfo.Should(Be.Null);
        }
예제 #7
0
        public void DeserializeProjectProcessChangedSagaDataAfterAddingFields()
        {
            const string oldSaga = @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Search.Bus.Workflow.ProjectProcessChangedSagaData, Tp.Search</Type>
  <Version>2</Version>
  <string>{""__type"":""ProjectProcessChangedSagaData:#Tp.Search.Bus.Workflow"",""Id"":""00000000-0000-0000-0000-000000000000"",""OriginalMessageId"":null,""Originator"":null,""ProjectId"":1,""SkipGenerals"":10}</string>
</Value>";

            var deserialized = (ProjectProcessChangedSagaData)BlobSerializer.Deserialize(XDocument.Parse(oldSaga), string.Empty);

            deserialized.ProjectId.Should(Be.EqualTo(1));
            deserialized.AssignablesRetrievedCount.Should(Be.EqualTo(0));
        }
예제 #8
0
        public void Test()
        {
            const string oldSaga = "<Value xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Type>Tp.Search.Bus.Workflow.IndexExistingEntitiesSagaData, Tp.Search</Type><Version>2</Version><string>{\"__type\":\"IndexExistingEntitiesSagaData:#Tp.Search.Bus.Workflow\",\"&lt;CommentsRetrievedCount&gt;k__BackingField\":0,\"&lt;GeneralsRetrievedCount&gt;k__BackingField\":0,\"&lt;Id&gt;k__BackingField\":\"4981ab85-8f0d-4a37-aa0b-a1c0010f88f0\",\"&lt;OriginalMessageId&gt;k__BackingField\":\"15a0e019-ace7-42b5-bc7d-f969c7270432\\1842090\",\"&lt;Originator&gt;k__BackingField\":\"Tp.Search@SHOTKIN\",\"&lt;OuterSagaId&gt;k__BackingField\":\"95a6b77a-1b9a-49cb-8e7c-a1c0010f8429\",\"&lt;SkipComments&gt;k__BackingField\":0,\"&lt;SkipGenerals&gt;k__BackingField\":30}</string></Value>\"";
            var          path    = new IndexExistingEntitiesSagaPreviousVersionCorrecter();

            path.NeedToApply(oldSaga).Should(Be.True);
            var text         = path.Apply(oldSaga);
            var deserialized = BlobSerializer.Deserialize(XDocument.Parse(text), string.Empty);
            var typed        = deserialized as IndexExistingEntitiesSagaData;

            typed.Should(Be.Not.Null);
            typed.Id.Should(Be.EqualTo(Guid.Parse("4981ab85-8f0d-4a37-aa0b-a1c0010f88f0")));
        }
        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"));
        }
예제 #10
0
        public void AttachToEntitySaga()
        {
            const string oldXml =
                @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
	<Type>Tp.Subversion.Workflow.AttachToEntitySagaData, Tp.Subversion</Type>
	<Version>2</Version>
	<string>{""__type"":""AttachToEntitySagaData:#Tp.Subversion.Workflow"",""EntityId"":0,""Id"":""c2afc097-6ea3-4a0e-8170-9fb400bb8bbe"",""OriginalMessageId"":""b4a0874e-6a92-4920-8e29-bea29a8ff361\\5498359"",""Originator"":""Tp.SubversionIntegration@TRUHTANOV"",""RevisionDto"":{""&lt;ID&gt;k__BackingField"":null,""&lt;AuthorID&gt;k__BackingField"":null,""&lt;CommitDate&gt;k__BackingField"":null,""&lt;Description&gt;k__BackingField"":null,""&lt;PluginProfileID&gt;k__BackingField"":null,""&lt;ProjectID&gt;k__BackingField"":null,""&lt;ProjectName&gt;k__BackingField"":null,""&lt;RevisionID&gt;k__BackingField"":1,""&lt;SourceControlID&gt;k__BackingField"":null}}</string>
</Value>
";
            var result =
                BlobSerializer.Deserialize(XDocument.Parse(oldXml), new TypeNameWithoutVersion(typeof(AttachToEntitySagaData)).Value) as
                AttachToEntitySagaData;

            result.Id.ToString().Should(Be.EqualTo("c2afc097-6ea3-4a0e-8170-9fb400bb8bbe"));
            result.RevisionDto.ID.Should(Be.EqualTo(1));
        }
예제 #11
0
        public void RevisionRangeInProfileStorage()
        {
            const string oldXml =
                @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Subversion.VersionControlSystem.RevisionRange, Tp.Subversion</Type>
  <Version>2</Version>
  <string>{""__type"":""RevisionRange:#Tp.Subversion.VersionControlSystem"",""FromChangeset"":{""__type"":""SvnRevisionId:#Tp.Subversion.Subversion"",""_value"":1},""ToChangeset"":{""__type"":""SvnRevisionId:#Tp.Subversion.Subversion"",""_value"":2}}</string>
</Value>
";
            var result =
                BlobSerializer.Deserialize(XDocument.Parse(oldXml), new TypeNameWithoutVersion(typeof(RevisionRange)).Value) as
                RevisionRange;

            result.FromChangeset.Value.Should(Be.EqualTo("1"));
            result.ToChangeset.Value.Should(Be.EqualTo("2"));
        }
예제 #12
0
        public void DeserializeAllDtos()
        {
            var assembly = Assembly.GetAssembly(typeof(ProjectDTO));

            Directory.GetFiles("SerializedDtos")
            .ForEach(fileName =>
            {
                var file = new FileInfo(fileName);
                var type = assembly.GetType("Tp.Integration.Common." + file.Name + "DTO") ?? assembly.GetType("Tp.Integration.Messages.Entities." + file.Name + "DTO");

                using (var reader = file.OpenRead())
                {
                    var xml = XDocument.Load(reader);
                    var dto = BlobSerializer.Deserialize(xml, type.Name);
                    dto.Should(Be.Not.Null);
                }
            });
        }
예제 #13
0
        public void CreateRevisionSaga()
        {
            const string oldXml =
                @"<Value xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
  <Type>Tp.Subversion.Workflow.CreateRevisionSagaData, Tp.Subversion</Type>
  <Version>2</Version>
  <string>{""__type"":""CreateRevisionSagaData:#Tp.Subversion.Workflow"",""&lt;Id&gt;k__BackingField"":""baf1a9ae-b874-44ea-827d-9fb400b48a78"",""&lt;OriginalMessageId&gt;k__BackingField"":""b4a0874e-6a92-4920-8e29-bea29a8ff361\\5498259"",""&lt;Originator&gt;k__BackingField"":""Tp.SubversionIntegration@TRUHTANOV"",""&lt;RevisionEntries&gt;k__BackingField"":[{""Action"":3,""Path"":""\/New\/test.txt""}],""&lt;RevisionFilesCreated&gt;k__BackingField"":0,""&lt;RevisionId&gt;k__BackingField"":0}</string>
</Value>
";
            var result =
                BlobSerializer.Deserialize(XDocument.Parse(oldXml), new TypeNameWithoutVersion(typeof(CreateRevisionSagaData)).Value) as
                CreateRevisionSagaData;

            result.Id.ToString().Should(Be.EqualTo("baf1a9ae-b874-44ea-827d-9fb400b48a78"));
            result.RevisionId.Should(Be.EqualTo(0));
            result.RevisionFilesCreated.Should(Be.EqualTo(0));
            result.RevisionEntries[0].Action.Should(Be.EqualTo(FileActionEnum.Modify));
            result.RevisionEntries[0].Path.Should(Be.EqualTo(@"/New/test.txt"));
        }
        public void EnsureXmlSerializerAppliedToOldSerializedData()
        {
            const string toDeserialize =
                @"<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>
										  <TestSagaData>
											<TestValue>testValue</TestValue>
											<Id>00000000-0000-0000-0000-000000000000</Id>
										  </TestSagaData>
										</Value>"                                        ;

            var toDeserializeXml = XDocument.Parse(toDeserialize);

            var profile = BlobSerializer.Deserialize(toDeserializeXml, typeof(ISagaEntity).Name);

            var typedProfile = profile as TestSagaData;

            typedProfile.Id.Should(Be.EqualTo(Guid.Empty));
            typedProfile.TestValue.Should(Be.EqualTo("testValue"));
        }
예제 #15
0
 public IMessage Retrieve()
 {
     return((IMessage)BlobSerializer.Deserialize(_serializedMsg, _type));
 }
 private object GetValueDeserialized()
 {
     _value      = BlobSerializer.Deserialize(ValueBlob, ValueKey);
     GetValueInt = GetValueCached;
     return(_value);
 }
예제 #17
0
 public T DeserializeAs <T>()
 {
     return((T)BlobSerializer.Deserialize(SagaEntity, typeof(T).Name));
 }
        public void ShouldThrowExceptionIfNoSerializersApplied()
        {
            var toDeserialize = XDocument.Parse("<SomeTag>Value</SomeTag>");

            BlobSerializer.Deserialize(toDeserialize, typeof(ISagaEntity).Name);
        }