Пример #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (Icon != null ? Icon.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Thumbnail != null ? Thumbnail.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ AllowAtRoot.GetHashCode();
         hashCode = (hashCode * 397) ^ (Master != null ? Master.GetHashCode() : 0);
         return(hashCode);
     }
 }
Пример #2
0
        public XmlElement ToXml(XmlDocument xd)
        {
            XmlElement doc = xd.CreateElement("DocumentType");

            // info section
            XmlElement info = xd.CreateElement("Info");

            doc.AppendChild(info);
            info.AppendChild(XmlHelper.AddTextNode(xd, "Name", GetRawText()));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Alias", Alias));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Icon", IconUrl));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Thumbnail", Thumbnail));
            info.AppendChild(XmlHelper.AddTextNode(xd, "Description", GetRawDescription()));
            info.AppendChild(XmlHelper.AddTextNode(xd, "AllowAtRoot", AllowAtRoot.ToString()));

            //TODO: Add support for mixins!
            if (this.MasterContentType > 0)
            {
                DocumentType dt = new DocumentType(this.MasterContentType);

                if (dt != null)
                {
                    info.AppendChild(XmlHelper.AddTextNode(xd, "Master", dt.Alias));
                }
            }


            // templates
            XmlElement allowed = xd.CreateElement("AllowedTemplates");

            foreach (template.Template t in allowedTemplates)
            {
                allowed.AppendChild(XmlHelper.AddTextNode(xd, "Template", t.Alias));
            }
            info.AppendChild(allowed);
            if (DefaultTemplate != 0)
            {
                info.AppendChild(
                    XmlHelper.AddTextNode(xd, "DefaultTemplate", new template.Template(DefaultTemplate).Alias));
            }
            else
            {
                info.AppendChild(XmlHelper.AddTextNode(xd, "DefaultTemplate", ""));
            }

            // structure
            XmlElement structure = xd.CreateElement("Structure");

            doc.AppendChild(structure);

            foreach (int cc in AllowedChildContentTypeIDs.ToList())
            {
                structure.AppendChild(XmlHelper.AddTextNode(xd, "DocumentType", new DocumentType(cc).Alias));
            }

            // generic properties
            XmlElement pts = xd.CreateElement("GenericProperties");

            foreach (PropertyType pt in PropertyTypes)
            {
                //only add properties that aren't from master doctype
                if (pt.ContentTypeId == this.Id)
                {
                    XmlElement ptx = xd.CreateElement("GenericProperty");
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Name", pt.GetRawName()));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Alias", pt.Alias));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Type", pt.DataTypeDefinition.DataType.Id.ToString()));

                    //Datatype definition guid was added in v4 to enable datatype imports
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Definition", pt.DataTypeDefinition.UniqueId.ToString()));

                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Tab", Tab.GetCaptionById(pt.TabId)));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Mandatory", pt.Mandatory.ToString()));
                    ptx.AppendChild(XmlHelper.AddTextNode(xd, "Validation", pt.ValidationRegExp));
                    ptx.AppendChild(XmlHelper.AddCDataNode(xd, "Description", pt.GetRawDescription()));
                    pts.AppendChild(ptx);
                }
            }
            doc.AppendChild(pts);

            // tabs
            var tabs = xd.CreateElement("Tabs");

            foreach (var propertyTypeGroup in PropertyTypeGroups)
            {
                //only add tabs that aren't from a master doctype
                if (propertyTypeGroup.ContentTypeId == this.Id)
                {
                    var tabx = xd.CreateElement("Tab");
                    tabx.AppendChild(XmlHelper.AddTextNode(xd, "Id", propertyTypeGroup.Id.ToString()));
                    tabx.AppendChild(XmlHelper.AddTextNode(xd, "Caption", propertyTypeGroup.Name));
                    tabs.AppendChild(tabx);
                }
            }

            doc.AppendChild(tabs);
            return(doc);
        }
Пример #3
0
 protected bool Equals(Info other)
 {
     return(base.Equals(other) && string.Equals(Icon, other.Icon) && string.Equals(Thumbnail, other.Thumbnail) && AllowAtRoot.Equals(other.AllowAtRoot) && string.Equals(Master, other.Master));
 }