Ejemplo n.º 1
0
        /// <include file='doc\ControlParser.uex' path='docs/doc[@for="ControlParser.ParseControl1"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public static Control ParseControl(IDesignerHost designerHost, string controlText, string directives)
        {
            if ((designerHost == null) || (controlText == null) || (controlText.Length == 0))
            {
                throw new ArgumentNullException();
            }

            if ((directives != null) && (directives.Length != 0))
            {
                controlText = directives + controlText;
            }

            DesignTimeParseData parseData = new DesignTimeParseData(designerHost, controlText);

            parseData.DataBindingHandler = GlobalDataBindingHandler.Handler;

            Control parsedControl = null;

            lock (typeof(LicenseManager)) {
                LicenseContext originalContext = LicenseManager.CurrentContext;
                try {
                    LicenseManager.CurrentContext = new WebFormsDesigntimeLicenseContext(designerHost);
                    LicenseManager.LockContext(licenseManagerLock);

                    parsedControl = DesignTimeTemplateParser.ParseControl(parseData);
                }
                catch (TargetInvocationException e) {
                    Debug.Assert(e.InnerException != null);
                    throw e.InnerException;
                }
                finally {
                    LicenseManager.UnlockContext(licenseManagerLock);
                    LicenseManager.CurrentContext = originalContext;
                }
            }
            return(parsedControl);
        }
 public void ParseControl_PermitOnly_ControlThreadUnmanagedCode()
 {
     DesignTimeTemplateParser.ParseControl(dtpd);
 }
 public void ParseControl_Deny_UnmanagedCode()
 {
     DesignTimeTemplateParser.ParseControl(dtpd);
 }
 public void ParseControl_Deny_ControlThread()
 {
     DesignTimeTemplateParser.ParseControl(dtpd);
 }