Ejemplo n.º 1
0
        /// <exclude />
	    public static TemplatePlaceholdersInfo GetRenderingPlaceHolders(Guid templateId)
        {
            XDocument document = GetTemplateDocument(templateId);
            IEnumerable<XElement> placeHoldersWithId = document.Descendants(RenderingElementNames.PlaceHolder).Where( e=>e.Attribute(RenderingElementNames.PlaceHolderIdAttribute)!=null);

            TemplatePlaceholdersInfo info = new TemplatePlaceholdersInfo();

            info.Placeholders = (
                from placeHolder in placeHoldersWithId
                orderby GetPlaceHolderTitle(placeHolder)
                select new KeyValuePair(
                    placeHolder.Attribute(RenderingElementNames.PlaceHolderIdAttribute).Value,
                    GetPlaceHolderTitle(placeHolder))).ToList();

            XAttribute defaultTrueAttribute = placeHoldersWithId.Attributes(RenderingElementNames.PlaceHolderDefaultAttribute).Where(a => a.Value == "true").FirstOrDefault();

            if (defaultTrueAttribute != null)
            {
                info.DefaultPlaceholderId = defaultTrueAttribute.Parent.Attribute(RenderingElementNames.PlaceHolderIdAttribute).Value;
            }
            else
            {
                if (info.Placeholders.Any())
                {
                    info.DefaultPlaceholderId = info.Placeholders.First().Key;
                }
            }

            return info;
        }
Ejemplo n.º 2
0
        /// <exclude />
        public static TemplatePlaceholdersInfo GetRenderingPlaceHolders(Guid templateId)
        {
            XDocument document = GetTemplateDocument(templateId);
            IEnumerable <XElement> placeHoldersWithId = document.Descendants(RenderingElementNames.PlaceHolder).Where(e => e.Attribute(RenderingElementNames.PlaceHolderIdAttribute) != null);

            TemplatePlaceholdersInfo info = new TemplatePlaceholdersInfo();

            info.Placeholders = (
                from placeHolder in placeHoldersWithId
                orderby GetPlaceHolderTitle(placeHolder)
                select new KeyValuePair(
                    placeHolder.Attribute(RenderingElementNames.PlaceHolderIdAttribute).Value,
                    GetPlaceHolderTitle(placeHolder))).ToList();

            XAttribute defaultTrueAttribute = placeHoldersWithId.Attributes(RenderingElementNames.PlaceHolderDefaultAttribute).Where(a => a.Value == "true").FirstOrDefault();

            if (defaultTrueAttribute != null)
            {
                info.DefaultPlaceholderId = defaultTrueAttribute.Parent.Attribute(RenderingElementNames.PlaceHolderIdAttribute).Value;
            }
            else
            {
                if (info.Placeholders.Any())
                {
                    info.DefaultPlaceholderId = info.Placeholders.First().Key;
                }
            }

            return(info);
        }