Esempio n. 1
0
 /// <summary>
 /// Add's the package item to the dynamic dictionary.
 /// </summary>
 /// <param name="item">The item being added.</param>
 /// <param name="nameissomethingverererelong">The name of the package item.</param>
 private dynamic GetDynamicItemFromTridionPackageItem(Item item)
 {
     if (item.ContentType == ContentType.Component)
     {
         Component component = _engine.GetObject(item.GetAsSource().GetValue("ID")) as Component;
         return(new ComponentModel(_engine, component));
     }
     else if (item.ContentType == ContentType.ComponentArray)
     {
         List <ComponentModel>      components             = new List <ComponentModel>();
         IComponentPresentationList componentPresentations = ComponentPresentationList.FromXml(item.GetAsString());
         foreach (ComponentPresentation cp in componentPresentations)
         {
             Component component = _engine.GetObject(cp.ComponentUri) as Component;
             components.Add(new ComponentModel(_engine, component));
         }
         return(components);
     }
     else if (item.ContentType == ContentType.ComponentPresentationArray)
     {
         List <ComponentPresentationModel> presentations          = new List <ComponentPresentationModel>();
         IComponentPresentationList        componentPresentations = ComponentPresentationList.FromXml(item.GetAsString());
         foreach (ComponentPresentation cp in componentPresentations)
         {
             presentations.Add(new ComponentPresentationModel(_engine, cp.ComponentUri, cp.TemplateUri));
         }
         return(presentations);
     }
     else
     {
         return(item.GetAsString());
     }
 }
        /// <summary>
        /// Gets the Component Presentations from the "Components" package item if available.
        /// </summary>
        /// <returns>A list of component presentations.</returns>
        public IComponentPresentationList GetComponentPresentations()
        {
            Item componentsItem = _package.GetByName(Package.ComponentsName);
            IComponentPresentationList componentPresentations = ComponentPresentationList.FromXml(componentsItem.GetAsString());

            return(componentPresentations);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a <see cref="T:Tridion.ContentManager.Templating.Package" /> as <see cref="T:Tridion.ContentManager.Templating.IComponentPresentationList" />
        /// </summary>
        /// <param name="package"><see cref="T:Tridion.ContentManager.Templating.Package" /></param>
        /// <param name="name">Name.</param>
        /// <returns>Value as <see cref="T:Tridion.ContentManager.Templating.IComponentPresentationList"/></returns>
        public static IComponentPresentationList ItemAsComponentList(this Package package, String name)
        {
            if (package != null)
            {
                String value = package.ItemAsString(name);

                if (!String.IsNullOrEmpty(value))
                {
                    return(ComponentPresentationList.FromXml(value));
                }
            }

            return(new ComponentPresentationList());
        }