private Control LoadControle(PageTemplateItem controlType)
        {
            Control ctrl = null;

            if (!String.IsNullOrEmpty(controlType.Assembly) && !String.IsNullOrEmpty(controlType.Class))
            {
                var instance = Activator.CreateInstance(controlType.Assembly, controlType.Class);
                ctrl = (Control)instance.Unwrap();

                if (!String.IsNullOrEmpty(controlType.Property) && !String.IsNullOrEmpty(controlType.Value))
                {
                    PropertyInfo[] properties = ctrl.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);

                    foreach (var property in properties)
                    {
                        if (property.Name.ToLower() == controlType.Property.ToLower())
                        {
                            property.SetValue(ctrl, controlType.Value, null);
                        }
                    }
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(controlType.Path))
                {
                    ctrl = _page.LoadControl(controlType.Path);
                }
            }

            return(ctrl);
        }
Esempio n. 2
0
        private void LoadMasterPageContentPlaceHolder(PageTemplateItem item)
        {
            PageTemplateItemBuilder builder = new PageTemplateItemBuilder(this, item);

            AddContentTemplate(item.Name, new CompiledTemplateBuilder(new BuildTemplateMethod(builder.BuildPageTemplateItem)));
        }
 public PageTemplateItemBuilder(Page page, PageTemplateItem item)
 {
     _page = page;
     _item = item;
 }