Example #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);
        }