Beispiel #1
0
        /// <summary>
        /// 从XML获取分组集合对象
        /// </summary>
        public static GroupSchemas GetSchemas(
            XmlDocument schemaXmlDoc,
            string localeid, bool bcross)
        {
            GroupSchemas gss = new GroupSchemas(bcross);

            if (schemaXmlDoc != null)
            {
                XmlElement root = schemaXmlDoc.DocumentElement;
                if (root != null)
                {
                    foreach (XmlElement ele in root.ChildNodes)
                    {
                        gss.Add(GroupSchemas.GetGroupSchemaFromXml(ele, localeid));
                    }
                }
            }

            // 如果没有无分组项,则要添加
            if (gss[GroupSchemas._xmlValueDefaultNoGroupId] == null)
            {
                if (bcross)
                {
                    gss.Add(GroupSchemas.GetDefaultCrossSchema());
                }
                else
                {
                    gss.Add(GroupSchemas.GetDefaultGroupSchema());
                }
            }

            // 如果还没有默认分组,取第一个分组为默认分组
            GroupSchema defaultSchema = gss[0];

            foreach (GroupSchema gs in gss)
            {
                if (gs.bDefault)
                {
                    defaultSchema = gs;
                    break;
                }
            }
            defaultSchema.bDefault = true;
            gss.Default            = defaultSchema;
            return(gss);
        }
Beispiel #2
0
        public static GroupSchemas GetSchemasNoSetDefaultSchema(
            string xml,
            string localeid)
        {
            XmlDocument schemaXmlDoc = null;

            if (!string.IsNullOrEmpty(xml))
            {
                schemaXmlDoc = new XmlDocument();
                schemaXmlDoc.LoadXml(xml);
            }

            GroupSchemas gss = new GroupSchemas(false);

            if (schemaXmlDoc != null)
            {
                XmlElement root = schemaXmlDoc.DocumentElement;
                if (root != null)
                {
                    foreach (XmlElement ele in root.ChildNodes)
                    {
                        gss.Add(GroupSchemas.GetGroupSchemaFromXml(ele, localeid));
                    }
                }
            }

            // 如果没有无分组项,则要添加
            if (gss[GroupSchemas._xmlValueDefaultNoGroupId] == null)
            {
                if (false)
                {
                    gss.Add(GroupSchemas.GetDefaultCrossSchema());
                }
                else
                {
                    gss.Add(GroupSchemas.GetDefaultGroupSchema());
                }
            }
            return(gss);
        }