public void Test() { _sagaState = new SoftwareProgrammingSagaState(Guid.NewGuid(), SoftwareProgrammingSaga.States.MakingCoffee); _sagaState.RememberPerson(Guid.NewGuid()); _sagaState.ClearEvents(); var data = DomainSerializer.Serialize(_sagaState); _restoredState = DomainSerializer.Deserialize <SoftwareProgrammingSagaState>(data); }
public void DomainSerializerTest() { var serializer = new DomainSerializer(); var customerRepository = new CustomerRepository(); var customer = customerRepository.CreateNew(0, "No"); customer.MainAddress = new Address("1", "1", null, null, new Phone("!23", 1), null); customer.OtherAddresses.AddRange(new[] { new Address("2", "2", null, null, new Phone("9123", 1), null), new Address("3", "3", null, null, new Phone("123123", 1), null), }); var serializedCustomer = serializer.Serialize(customer); var customerCopy = serializer.Deserialize <Customer>(serializedCustomer); Assert.IsTrue(ObjectComparer.Default.DeepEquals(customer, customerCopy)); var invoiceRepository = new InvoiceRepository(); var invoice = invoiceRepository.Create(); var line = invoice.CreateNewLine(); line.Quantity = 0.5m; line.ProductId = 1; line.SetKey(1); line = invoice.CreateNewLine(); line.Quantity = 0.7m; line.ProductId = 2; line.SetKey(2); var serializedInvoice = serializer.Serialize(invoice); var invoiceCopy = serializer.Deserialize <Invoice>(serializedInvoice); Assert.IsTrue(ObjectComparer.Default.DeepEquals(invoice, invoiceCopy)); }
public static EnumerationItem[] CreateEnumerationDefaults() { //var res = new[] //{ // new EnumerationItem() // { // Id = EnumerationConst.Root, // Title = "Enumerations", // TypeId = SysConst.NullGuid // }, // new EnumerationItem() // { // Id = EnumerationConst.TypeEnum, // Title = "Enumeration Types", // TypeId = EnumerationConst.Root // }, // new EnumerationItem() // { // Id = EnumerationConst.GenderEnum, // Title = "Genders", // TypeId = EnumerationConst.TypeEnum, // }, // new EnumerationItem() // { // Id = EnumerationConst.GenderMaleEnum, // Title = "Male", // TypeId = EnumerationConst.GenderEnum // }, // new EnumerationItem() // { // Id = EnumerationConst.GenderFemaleEnum, // Title = "Female", // TypeId = EnumerationConst.GenderEnum // }, // new EnumerationItem() // { // Id = EnumerationConst.GenderUnknownEnum, // Title = "Unknown", // TypeId = EnumerationConst.GenderEnum // } //}; var path = HostingEnvironment.MapPath(MediaServiceConst.DefaultEnumerationsXmlPath); // DomainSerializer<EnumerationItem[]>.Serialize(res,path); return(DomainSerializer <EnumerationItem[]> .Deserialize(path)); }
/// <summary> /// Gets the deserialized domain objects. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="name">The name.</param> /// <param name="func">The function.</param> /// <returns>List{``0}.</returns> public List <T> GetDeserializedDomainObjects <T>(XName name, Func <XElement, bool> func) where T : DomainObject <T> { Elements = GetXElements(name, func); return(Elements == null || Elements.Count() == 0 ? new List <T>() : DomainSerializer <List <T> > .Deserialize(Elements.FirstOrDefault())); }
public void LoadBoutiqueOptions() { BoutiqueOptions = DomainSerializer <ObservableCollection <BoutiqueOption> > .Deserialize(XmlConfigPath); }