private void SerializeBlockInfos(CDomContainer container) { CDomListSection blocksSection = container.CreateListSection(NODE_CIPSECTION); foreach (CBlockInPackageInfo info in BlocksInPackage) { CDomSection itemSection = blocksSection.CreateSection(); itemSection.Set(NODE_LIST_NUMBER, info.Number); itemSection.Set(NODE_LIST_OFFSET, info.Offset); itemSection.Set(NODE_LIST_LENGTH, info.Length); } }
public void TestContainer() { TPersonForSerialization person = CreatePerson(); CDomContainer container = CDomContainer.CreateContainer("Person"); TPersonForSerialization.Serialize(person, container); Console.WriteLine(container.SerializeToString()); XmlDocument doc = CXmlHelper.LoadDocument(container.SerializeToString()); CDomContainer deserializedContainer = new CDomContainer(doc); TPersonForSerialization deserializedEmployee = TPersonForSerialization.Deserialize(deserializedContainer); Console.WriteLine(deserializedContainer.SerializeToString()); }
public static void Serialize(TPersonForSerialization person, CDomContainer container) { container.Set("FirstName", person.FirstName); container.Set("LastName", person.LastName); container.Set("Age", person.Age); container.Set("Weight", person.Weight); container.Set("Height", person.Height); CDomSection section = container.CreateSection("Employee"); section.Set("Company", person.EmployeeInfo.CompanyName); section.Set("EmployeeId", person.EmployeeInfo.EmployeeId); section.Set("Position", person.EmployeeInfo.Position); CDomListSection listSection = container.CreateListSection("children"); foreach (TPersonChildren child in person.PersonChildrens) { CDomSection childSection = listSection.CreateSection(); childSection.Set("Name", child.Name); childSection.Set("Age", child.Age); childSection.Set("Gender", (Int32)child.Gender); } }
public static TPersonForSerialization Deserialize(CDomContainer container) { TPersonForSerialization person = new TPersonForSerialization(); person.FirstName = container.GetString("FirstName"); person.LastName = container.GetString("LastName"); person.Age = container.GetInt32("Age"); person.Weight = container.GetInt32("Weight"); person.Height = container.GetInt32("Height"); CDomSection employeeSection = container.GetSection("Employee"); person.EmployeeInfo = new TEmployeeInfo() { CompanyName = employeeSection.GetString("Company"), Position = employeeSection.GetString("Position"), EmployeeId = employeeSection.GetInt32("EmployeeId") }; return person; }
public static void Serialize(CPackageSummaryInfo summaryInfo, CDomContainer container) { container.Set(NODE_ALGORITHM, (Int32)summaryInfo.CompressionAlgorithm); summaryInfo.SerializeBlockInfos(container); }
public static CDomContainer Serialize(CPackageSummaryInfo summaryInfo) { CDomContainer container = new CDomContainer(NODE_PACKAGESUMMARY); Serialize(summaryInfo, container); return container; }