private void ParseClassProps(XmlReader xrdr, List<ModelProperty> props) { if (xrdr.IsEmptyElement) { xrdr.Read(); xrdr.MoveToContent(); return; } if (!xrdr.Read()) // <props> return; xrdr.MoveToContent(); while (xrdr.IsStartElement()) { ModelProperty.Types type = ModelProperty.Types.Basic; switch (xrdr.Name) { case "basic": type = ModelProperty.Types.Basic; break; case "owning": type = ModelProperty.Types.Owning; break; case "rel": type = ModelProperty.Types.Reference; break; default: throw new Exception("Expected property element!"); } string sName = xrdr.GetAttribute("id"); string sSig = xrdr.GetAttribute("sig"); bool fAtomic = xrdr.GetAttribute("card") == "atomic"; ModelProperty mprop = new ModelProperty(sName, type, sSig, fAtomic); props.Add(mprop); xrdr.ReadOuterXml(); // swallows any comments or notes on the property. xrdr.MoveToContent(); } xrdr.ReadEndElement(); // </props> xrdr.MoveToContent(); }
/// <summary> /// If this property's DTD definition would subsume the other property's DTD definition, /// then return true. /// </summary> public bool DtdSubsumes(ModelProperty that) { if (this.Equals(that)) return true; switch (this.Type) { case Types.Basic: if (that.Type != Types.Basic) return false; if (this.Sig == that.Sig) return true; switch (this.Sig) { case "Boolean": case "GenDate": case "Guid": case "Integer": case "Time": return (that.Sig == "Boolean" || that.Sig == "GenDate" || that.Sig == "Guid" || that.Sig == "Integer" || that.Sig == "Time"); case "Binary": case "MultiString": case "MultiUnicode": case "String": case "TextPropBinary": case "Unicode": break; } return false; case Types.Owning: case Types.Reference: if (that.Type == Types.Basic) return false; else if (this.IsAtomic == that.IsAtomic) return true; else return that.IsAtomic; } return true; }