private OrmHierarchyRootAttribute CreateOrmHierarchyRootAttribute(TestAttributeValuesType valuesType) { OrmHierarchyRootAttribute originalAttribute = new OrmHierarchyRootAttribute(); bool isValues1 = valuesType == TestAttributeValuesType.Values1; originalAttribute.Enabled = isValues1 ? true : false; originalAttribute.IncludeTypeId.SetAsCustom(isValues1 ? false : true); originalAttribute.InheritanceSchema = isValues1 ? HierarchyRootInheritanceSchema.ConcreteTable : HierarchyRootInheritanceSchema.SingleTable; originalAttribute.MappingName.SetAsCustom(isValues1 ? "tTable1" : "RevertedtTable1"); return(originalAttribute); }
private void TestSerializationForOrmHierarchyRootAttribute() { const string referentialXml = "<content valueType=\"Enabled\"><value inheritanceSchema=\"ConcreteTable\"><includeTypeId valueType=\"Custom\" value=\"False\" /><mappingName valueType=\"Custom\"><value>tTable1</value></mappingName></value></content>"; OrmHierarchyRootAttribute originalAttribute = CreateOrmHierarchyRootAttribute( TestAttributeValuesType.Values1); string xml = originalAttribute.SerializeToString(); Assert.IsTrue(Util.StringEqual(xml, referentialXml, true), "Serialized xml form of 'OrmHierarchyRootAttribute' type differs from referential xml."); OrmHierarchyRootAttribute clonedAttribute = null; Action cloneAttribute = () => clonedAttribute = (OrmHierarchyRootAttribute)originalAttribute.Clone(); cloneAttribute(); Assert.IsTrue(originalAttribute.EqualsTo(clonedAttribute)); Action testClonedNotEquals = () => Assert.IsFalse(originalAttribute.EqualsTo(clonedAttribute)); clonedAttribute.IncludeTypeId.SetAsDefault(); testClonedNotEquals(); cloneAttribute(); clonedAttribute.InheritanceSchema = HierarchyRootInheritanceSchema.ClassTable; testClonedNotEquals(); cloneAttribute(); clonedAttribute.MappingName.SetAsCustom("123"); testClonedNotEquals(); cloneAttribute(); clonedAttribute.MappingName.SetAsDefault(); testClonedNotEquals(); }
private static void CustomReadPropertiesFromElements(SerializationContext serializationContext, Entity element, XmlReader reader) { while (!serializationContext.Result.Failed && !reader.EOF && reader.NodeType == global::System.Xml.XmlNodeType.Element) { switch (reader.LocalName) { case "hierarchyRoot": { if (reader.IsEmptyElement) { // No serialized value, must be default one. SerializationUtilities.Skip(reader); // Skip this tag. } else { OrmHierarchyRootAttribute hierarchyRootAttribute = new OrmHierarchyRootAttribute(); hierarchyRootAttribute.DeserializeFromXml(reader, "hierarchyRoot"); element.HierarchyRootAttribute = hierarchyRootAttribute; SerializationUtilities.SkipToNextElement(reader); reader.SkipToNextElementFix(); } break; } case "keyGenerator": { if (reader.IsEmptyElement) { // No serialized value, must be default one. SerializationUtilities.Skip(reader); // Skip this tag. } else { OrmKeyGeneratorAttribute keyGeneratorAttr = new OrmKeyGeneratorAttribute(); keyGeneratorAttr.DeserializeFromXml(reader, "keyGenerator"); element.KeyGenerator = keyGeneratorAttr; SerializationUtilities.SkipToNextElement(reader); reader.SkipToNextElementFix(); } break; } case "typeDiscriminatorValue": { if (reader.IsEmptyElement) { // No serialized value, must be default one. SerializationUtilities.Skip(reader); // Skip this tag. } else { OrmTypeDiscriminatorValueAttribute typeDiscriminatorValue = new OrmTypeDiscriminatorValueAttribute(); typeDiscriminatorValue.DeserializeFromXml(reader); element.TypeDiscriminatorValue = typeDiscriminatorValue; SerializationUtilities.SkipToNextElement(reader); reader.SkipToNextElementFix(); } break; } default: return; // Don't know this element. } } }