Inheritance: TemplateControlParser
示例#1
0
        /*
         * Compile an .ascx file into a UserControl derived Type
         */
        internal static Type GetCompiledUserControlType(string virtualPath,
                                                        string inputFile, HttpContext context)
        {
            CheckUserControlFileExtension(virtualPath);

            // We need unrestricted permission to process the UserControl file
            InternalSecurityPermissions.Unrestricted.Assert();

            UserControlParser parser = new UserControlParser();

            Type t = null;

            // Suspend client impersonation (for compilation)
            HttpContext.ImpersonationSuspendContext ictx = context.Impersonation.SuspendIfClient();

            try {
                try {
                    t = parser.GetCompiledType(virtualPath, inputFile, context);
                }
                finally {
                    // Resume client impersonation
                    ictx.Resume();
                }
            }
            catch { throw; } // Prevent Exception Filter Security Issue (ASURT 122835)

            return(t);
        }
示例#2
0
        public static Type GetCompiledType(string virtualPath, string inputFile, HttpContext context)
        {
#if NET_2_0
            UserControlParser ucp = new UserControlParser(new VirtualPath(virtualPath), inputFile, context);
#else
            UserControlParser ucp = new UserControlParser(virtualPath, inputFile, context);
#endif
            return(ucp.CompileIntoType());
        }
        /*
         * Compile a nested .ascx file (a User Control) and return its Type
         */
        private Type GetUserControlType(string virtualPath)
        {
            UserControlParser.CheckUserControlFileExtension(virtualPath);

            if (FInDesigner)
            {
                return(typeof(UserControl));
            }
            return(GetReferencedType(new UserControlParser(), virtualPath));
        }
        /// <include file='doc\TemplateControl.uex' path='docs/doc[@for="TemplateControl.LoadTemplate"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Obtains an instance of the <see langword='ITemplate'/> interface from an
        ///       external file.
        ///    </para>
        /// </devdoc>
        public ITemplate LoadTemplate(string virtualPath)
        {
            // If it's relative, make it absolute.  Treat is as relative to this
            // user control (ASURT 55513)
            virtualPath = UrlPath.Combine(TemplateSourceDirectory, virtualPath);

            // Compile the declarative template and get its Type
            Type t = UserControlParser.GetCompiledUserControlType(virtualPath,
                                                                  null, Context);

            return(new SimpleTemplate(t));
        }
示例#5
0
        Type GetTypeFromControlPath(string virtualPath)
        {
            if (virtualPath == null)
            {
                throw new ArgumentNullException("virtualPath");
            }

            string vpath = UrlUtils.Combine(TemplateSourceDirectory, virtualPath);

#if NET_2_0
            return(BuildManager.GetCompiledType(vpath));
#else
            string realpath = Context.Request.MapPath(vpath);
            return(UserControlParser.GetCompiledType(vpath, realpath, Context));
#endif
        }
示例#6
0
        public Control ParseControl(string content)
        {
            if (content == null)
            {
                throw new ArgumentNullException("content");
            }

#if NET_2_0
            // FIXME: This method needs to be rewritten in some sane way - the way it is now,
            // is a kludge. New version should not use
            // UserControlParser.GetCompiledType, but instead resort to some other way
            // of creating the content (template instantiation? BuildManager? TBD)
            TextReader reader  = new StringReader(content);
            Type       control = UserControlParser.GetCompiledType(reader, content.GetHashCode(), HttpContext.Current);
            if (control == null)
            {
                return(null);
            }

            TemplateControl parsedControl = Activator.CreateInstance(control, null) as TemplateControl;
            if (parsedControl == null)
            {
                return(null);
            }

            if (this is System.Web.UI.Page)
            {
                parsedControl.Page = (System.Web.UI.Page) this;
            }
            parsedControl.FrameworkInitialize();

            Control   ret   = new Control();
            int       count = parsedControl.Controls.Count;
            Control[] parsedControlControls = new Control [count];
            parsedControl.Controls.CopyTo(parsedControlControls, 0);

            for (int i = 0; i < count; i++)
            {
                ret.Controls.Add(parsedControlControls [i]);
            }

            parsedControl = null;
            return(ret);
#else
            return(null);
#endif
        }
示例#7
0
		public static Type GetCompiledType (string virtualPath, string inputFile, HttpContext context)
		{
			UserControlParser ucp = new UserControlParser (new VirtualPath (virtualPath), inputFile, context);

			return ucp.CompileIntoType ();
		}
示例#8
0
		internal static Type GetCompiledType (string virtualPath, string inputFile, List <string> deps, HttpContext context)
		{
			UserControlParser ucp = new UserControlParser (new VirtualPath (virtualPath), inputFile, deps, context);

			return ucp.CompileIntoType ();
		}
示例#9
0
		internal static Type GetCompiledType (TextReader reader, int? inputHashCode, HttpContext context)
		{
			UserControlParser ucp = new UserControlParser (reader, inputHashCode, context);
			return ucp.CompileIntoType ();
		}
示例#10
0
 private static ITemplate ParseTemplate(string content, VirtualPath virtualPath, bool ignoreFilter) {
     TemplateParser parser = new UserControlParser();
     return parser.ParseTemplateInternal(content, virtualPath, ignoreFilter);
 }
示例#11
0
		public static Type CompileUserControlType (UserControlParser parser)
		{
			UserControlCompiler pc = new UserControlCompiler (parser);
			return pc.GetCompiledType ();
		}
示例#12
0
		public UserControlCompiler (UserControlParser parser)
			: base (parser)
		{
			this.parser = parser;
		}
示例#13
0
        internal static Type GetCompiledType(string virtualPath, string inputFile, List <string> deps, HttpContext context)
        {
            UserControlParser ucp = new UserControlParser(new VirtualPath(virtualPath), inputFile, deps, context);

            return(ucp.CompileIntoType());
        }
示例#14
0
        internal static Type GetCompiledType(TextReader reader, int?inputHashCode, HttpContext context)
        {
            UserControlParser ucp = new UserControlParser(reader, inputHashCode, context);

            return(ucp.CompileIntoType());
        }
		internal static Type GetCompiledType (string virtualPath, string inputFile, ArrayList deps, HttpContext context)
		{
#if NET_2_0
			UserControlParser ucp = new UserControlParser (new VirtualPath (virtualPath), inputFile, deps, context);
#else
			UserControlParser ucp = new UserControlParser (virtualPath, inputFile, deps, context);
#endif
			return ucp.CompileIntoType ();
		}
 internal UserControlCodeDomTreeGenerator(UserControlParser ucParser) : base(ucParser)
 {
     this._ucParser = ucParser;
 }