private DemoDto CreateDemoDto() { DemoDto dto = new DemoDto { DemoId = "1", DemoName = "Data Transfer Object Demonstration Program", DemoProgrammer = "Kenny Young" }; return(dto); }
private void ProcessDemo() { DemoDto dto = this.CreateDemoDto(); // Write the deserialized dto values. Console.WriteLine("Not Serialized DTO"); Console.WriteLine("======================="); Console.WriteLine("\r"); Console.WriteLine("DemoId : " + dto.DemoId); Console.WriteLine("Demo Name : " + dto.DemoName); Console.WriteLine("Demo Programmer: " + dto.DemoProgrammer); Console.WriteLine("\r"); // Serialize the dto to xml. string strXml = DtoSerializerHelper.SerializeDto(dto); // Write the serialized dto as xml. Console.WriteLine(); Console.WriteLine("Serialized DTO"); Console.WriteLine("======================="); Console.WriteLine("\r"); Console.WriteLine(strXml); Console.WriteLine("\r"); // Deserialize the xml to the data transfer object. DemoDto desDto = (DemoDto)DtoSerializerHelper.DeserializeXml(strXml, new DemoDto()); Assert.AreEqual(dto.DemoId, desDto.DemoId); Assert.AreEqual(dto.DemoName, desDto.DemoName); Assert.AreEqual(dto.DemoProgrammer, desDto.DemoProgrammer); // Write the deserialized dto values. Console.WriteLine("Deseralized DTO"); Console.WriteLine("======================="); Console.WriteLine("\r"); Console.WriteLine("DemoId : " + desDto.DemoId); Console.WriteLine("Demo Name : " + desDto.DemoName); Console.WriteLine("Demo Programmer: " + desDto.DemoProgrammer); Console.WriteLine("\r"); }