Beispiel #1
0
        public static DataTypeDefinition Import(XmlNode xmlData)
        {
            string _name = xmlData.Attributes["Name"].Value;
            string _id   = xmlData.Attributes["Id"].Value;
            string _def  = xmlData.Attributes["Definition"].Value;


            //Make sure that the dtd is not already present
            if (!CMSNode.IsNode(new Guid(_def))
                )
            {
                BasePages.UmbracoEnsuredPage uep = new umbraco.BasePages.UmbracoEnsuredPage();
                BusinessLogic.User           u   = uep.getUser();

                if (u == null)
                {
                    u = BusinessLogic.User.GetUser(0);
                }

                cms.businesslogic.datatype.controls.Factory f = new umbraco.cms.businesslogic.datatype.controls.Factory();


                DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def));
                dtd.DataType = f.DataType(new Guid(_id));
                dtd.Save();

                //add prevalues
                foreach (XmlNode xmlPv in xmlData.SelectNodes("PreValues/PreValue"))
                {
                    XmlAttribute val = xmlPv.Attributes["Value"];

                    if (val != null && !string.IsNullOrEmpty(val.Value))
                    {
                        PreValue p = new PreValue(0, 0, val.Value);
                        p.DataTypeId = dtd.Id;
                        p.Save();
                    }
                }

                return(dtd);
            }

            return(null);
        }