예제 #1
0
        private AOITemplate CreateAOITemplate(XElement element)
        {
            AOITemplate aoi   = new AOITemplate();
            string      value = AttributeValue(element, "name");

            if (!String.IsNullOrEmpty(value))
            {
                aoi.Name = value;
            }
            value = AttributeValue(element, "template");
            if (!String.IsNullOrEmpty(value))
            {
                aoi.Template = value;
            }
            value         = AttributeValue(element, "ischecked");
            aoi.IsChecked = value == "true";
            value         = AttributeValue(element, "isreverse");
            aoi.IsReverse = value == "true";
            return(aoi);
        }
예제 #2
0
        private ProductDef CreatProduct(XElement element, ThemeDef theme)
        {
            ProductDef product = new ProductDef();

            product.Theme = theme;
            string value = element.Attribute("name").Value;

            if (!String.IsNullOrEmpty(value))
            {
                product.Name = value;
            }
            value = element.Attribute("image").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.Image = value;
            }
            value = element.Attribute("group").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.Group = value;
            }
            value = element.Attribute("uiprovider").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.UIProvider = value;
            }
            value = element.Attribute("identify").Value;
            if (!String.IsNullOrEmpty(value))
            {
                product.Identify = value;
            }
            IEnumerable <XElement> subProductsElements = element.Element(XName.Get("SubProducts")).Elements();

            if (subProductsElements != null && subProductsElements.Count() != 0)
            {
                SubProductDef        subPro;
                List <SubProductDef> subs = new List <SubProductDef>();
                foreach (XElement ele in subProductsElements)
                {
                    subPro = CreatSubProduct(ele);
                    if (subPro != null)
                    {
                        subs.Add(subPro);
                    }
                    subPro.ProductDef = product;
                    //Console.WriteLine("SubProduct:"+ele.Attribute("name").Value);
                }
                if (subs != null && subs.Count != 0)
                {
                    product.SubProducts = subs.ToArray();
                }
            }
            IEnumerable <XElement> aoisElements = Elements(element.Element("AOITemplates"));

            if (aoisElements != null && aoisElements.Count() != 0)
            {
                List <AOITemplate> aoiList = new List <AOITemplate>();
                foreach (XElement ele in aoisElements)
                {
                    AOITemplate aoi = CreateAOITemplate(ele);
                    if (aoi != null)
                    {
                        aoiList.Add(aoi);
                    }
                }
                product.AOITemplates = aoiList.ToArray();
            }
            return(product);
        }