Ejemplo n.º 1
0
        public TemplatedControl()
        {
            TemplateAttribute templateAttribute = AttributeSearcher.GetAttribute <TemplateAttribute>(GetType());

            if (templateAttribute != null)
            {
                LoadTemplate(templateAttribute.FileName);
            }
        }
Ejemplo n.º 2
0
        private IList <TemplateElementAttribute> GetBindableMembers()
        {
            List <TemplateElementAttribute> list = new List <TemplateElementAttribute>();
            Type type = GetType();

            while (type != typeof(TemplatedControl))
            {
                list.AddRange(AttributeSearcher.GetMemberAttributes <TemplateElementAttribute>(type, false));
                type = type.BaseType;
            }
            return(list);
        }
Ejemplo n.º 3
0
        private void LoadTemplate(string templateFile)
        {
            _templateFile = templateFile;
            ITemplate ascx = GetTemplate(_templateFile);

            Controls.Clear();
            ascx.InstantiateIn(this);
            Controls[0].ID = "_";

            _templateElements = AttributeSearcher.GetMemberAttributes <TemplateElementAttribute>(GetType(), true);
            BindTemplateElements(false);
        }
Ejemplo n.º 4
0
 protected void BindMemberControls(Control container)
 {
     foreach (TemplateElementAttribute element in AttributeSearcher.GetMemberAttributes <TemplateElementAttribute>(this.GetType(), false))
     {
         Control control = ControlsSearcher.FindControl(container, element.ID);
         if (control == null && !element.CanBeNull)
         {
             throw new InvalidOperationException(String.Format("Element {0} not found in parent control {1}", element.ID, control.ID));
         }
         else
         {
             element[this] = control;
         }
     }
 }