public ContractRegistry LoadContractRegistry() { var data = this.LoadData(this.integration.contractRegistryAddress); this.integration.logger.LogTrace("Received registry data: " + data.Length + " bytes"); if (data.Length == 0) { return(new ContractRegistry()); } return(StatefulObject.Create <ContractRegistry>( StateSerialization.DeserializeState(data))); }
public void Serializes_And_Deserializes_State() { var state = new Dictionary <string, object>() { { "testString", "string value with \n newlines and \t tabs" }, { "testInt", 15 }, { "testDecimal", 15.0m }, { "testBoolean", true }, { "testDictionary", new Dictionary <string, object>() { { "nestedString", "another string value \0 with a null byte" }, { "nestedInt", 42 }, { "nestedTrue", true }, { "nestedFalse", false }, } }, { "testList", new List <object>() { "A string, and an int (- - )", 103, true, } }, }; var serialized = StateSerialization.SerializeState(state); var deserialized = StateSerialization.DeserializeState(serialized); var reserialized = StateSerialization.SerializeState(deserialized); Assert.Equal(serialized, reserialized); Assert.Equal(state, deserialized); }