Exemplo n.º 1
0
        private List <AgnaImage> ParseImages(XElement imagesParent)
        {
            List <AgnaImage> returnImages = new List <AgnaImage>();

            //Parse main images
            for (int i = 0; i < imagesParent.Element("main").Elements("image").Count(); i++)
            {
                if (AgnaImage.isMainAgnaImage(imagesParent.Element("main").Elements("image").ElementAt(i)))
                {
                    returnImages.Add(new AgnaImage(imagesParent.Element("main").Elements("image").ElementAt(i), AgnaImage.FieldType.Main));
                }
            }

            //Parse custom images
            if (imagesParent.Elements("custom").Count() != 1 || imagesParent.Element("custom").Elements("image").Count() == 0)
            {
                return(returnImages);
            }

            for (int i = 0; i < imagesParent.Element("custom").Elements("image").Count(); i++)
            {
                if (AgnaImage.isAgnaImage(imagesParent.Element("custom").Elements("image").ElementAt(i)))
                {
                    returnImages.Add(new AgnaImage(imagesParent.Element("custom").Elements("image").ElementAt(i), AgnaImage.FieldType.Custom));
                }
            }

            return(returnImages);
        }
Exemplo n.º 2
0
            public AgnaImageCategory(XElement xElement) : base(xElement)
            {
                //Clear all pre-existing nodes/attributes from the base constructor
                RemoveAll();

                //If attribute 'name' and 'path' is not null, either use them or 'null'
                ReplaceAttributes(new XAttribute("name", xElement.Attribute("name") != null ?
                                                 !String.IsNullOrEmpty(xElement.Attribute("name").Value) ? xElement.Attribute("name").Value : "category" :
                                                 "null"),
                                  xElement.Attribute("path") != null ? xElement.Attribute("path") : null
                                  );

                //Parse valid Agna Images from xElement
                foreach (XElement image in xElement.Elements("image"))
                {
                    if (AgnaImage.isAgnaImage(image))
                    {
                        Add(new AgnaImage(image));
                        _Images.Add(new AgnaImage(image));
                    }
                }
            }