Example #1
0
        public Control LoadControl(Type type, object[] parameters)
        {
            object [] attrs = null;

            if (type != null)
            {
                type.GetCustomAttributes(typeof(PartialCachingAttribute), true);
            }
            if (attrs != null && attrs.Length == 1)
            {
                PartialCachingAttribute attr = (PartialCachingAttribute)attrs [0];
                PartialCachingControl   ctrl = new PartialCachingControl(type, parameters);
                ctrl.VaryByParams   = attr.VaryByParams;
                ctrl.VaryByControls = attr.VaryByControls;
                ctrl.VaryByCustom   = attr.VaryByCustom;
                return(ctrl);
            }

            object control = Activator.CreateInstance(type, parameters);

            if (control is UserControl)
            {
                ((UserControl)control).InitializeAsUserControl(Page);
            }

            return((Control)control);
        }
Example #2
0
		public Control LoadControl (Type type, object[] parameters) 
		{
			object [] attrs = null;

			if (type != null)
				type.GetCustomAttributes (typeof (PartialCachingAttribute), true);
			if (attrs != null && attrs.Length == 1) {
				PartialCachingAttribute attr = (PartialCachingAttribute) attrs [0];
				PartialCachingControl ctrl = new PartialCachingControl (type, parameters);
				ctrl.VaryByParams = attr.VaryByParams;
				ctrl.VaryByControls = attr.VaryByControls;
				ctrl.VaryByCustom = attr.VaryByCustom;
				return ctrl;
			}

			object control = Activator.CreateInstance (type, parameters);
			if (control is UserControl)
				((UserControl) control).InitializeAsUserControl (Page);

			return (Control) control;
		}