Exemple #1
0
 /// <summary>
 /// Loads a collection of all template slots that are declaratively
 /// defined  in the page template. The slots that are specified as being blocked
 /// in the assembly instructions are not processed.
 /// </summary>
 private void loadTemplateSlots()
 {
     foreach (TemplateSlot slot in this.FindControlByType <TemplateSlot>())
     {
         //Add to slot collection only if it is not marked as being blocked.
         TemplateSlots.Add(slot);
     }
 }
Exemple #2
0
 /// <summary>
 /// Loads a collection of all template slots that are declaratively
 /// defined  in the page template. The slots that are specified as being blocked
 /// in the assembly instructions are not processed.
 /// </summary>
 private void loadTemplateSlots()
 {
     foreach (TemplateSlot slot in this.FindControlByType <TemplateSlot>())
     {
         //Add to slot collection only if it is not marked as being blocked.
         if (!PageAssemblyInstruction.BlockedSlotNames.Contains(slot.ID))
         {
             TemplateSlots.Add(slot);
         }
     }
 }
Exemple #3
0
        /// <summary>
        /// Adds the snippet info from the PageAssembly instruction for each
        /// page template slot. Use the ID of the template slot control to match
        /// the snippet info slotname property.
        /// </summary>
        private void loadSnippetsIntoTemplateSlots()
        {
            if (TemplateSlots.Count > 0)
            {
                List <SnippetControl> supportingSnippets = new List <SnippetControl>();
                foreach (SnippetInfo snippet in PageAssemblyInstruction.Snippets)
                {
                    if (!String.IsNullOrEmpty(snippet.SlotName))
                    {
                        string slotName = snippet.SlotName.Trim();
                        if (TemplateSlots.ContainsSlotName(slotName))
                        {
                            try
                            {
                                SnippetControl snippetControl = (SnippetControl)Page.LoadControl(snippet.SnippetTemplatePath.Trim());

                                // Note this has to come before adding the template control to the control tree.
                                // This way, we can be sure any event in the control lifecycle like OnInit()
                                // already has the snippet info data.
                                snippetControl.SnippetInfo = snippet;

                                TemplateSlots[slotName].AddSnippet(snippetControl);

                                // Some snippetcontrol implement the ISupportingSnippet interface.
                                // The controls which implement ISupportingSnippet will provide additional
                                // snippet control that are required for the complete functionality.
                                // Add them to a collection that will be processed later.
                                if (snippetControl is ISupportingSnippet)
                                {
                                    SnippetControl[] supportingcontrols = ((ISupportingSnippet)snippetControl).GetSupportingSnippets();
                                    if (supportingcontrols != null)
                                    {
                                        supportingSnippets.AddRange(supportingcontrols);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                //Failed to load the slot template control. Log this error.
                                log.ErrorFormat("Failed to load snippet control: {0}", ex, snippet.SnippetTemplatePath);
                            }
                        }
                    }
                }

                foreach (SnippetControl supportSnippet in supportingSnippets)
                {
                    try
                    {
                        if (TemplateSlots.ContainsSlotName(supportSnippet.SnippetInfo.SlotName))
                        {
                            TemplateSlots[supportSnippet.SnippetInfo.SlotName].AddSnippet(supportSnippet);
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error("Failed to add supporting snippet control", ex);
                    }
                }
            }
        }