Inheritance: UserControlParser
Example #1
0
        internal static MasterPage CreateMasterPage(TemplateControl owner, HttpContext context,
                                                    string masterPageFile, IDictionary contentTemplateCollection)
        {
            var req = context.Request;

            if (req != null)
            {
                masterPageFile = HostingEnvironment.VirtualPathProvider.CombineVirtualPaths(req.CurrentExecutionFilePath, masterPageFile);
            }
#if TARGET_JVM
            MasterPage masterPage = MasterPageParser.GetCompiledMasterInstance(masterPageFile,
                                                                               owner.Page.MapPath(masterPageFile),
                                                                               context);
#else
            MasterPage masterPage = BuildManager.CreateInstanceFromVirtualPath(masterPageFile, typeof(MasterPage)) as MasterPage;
#endif
            if (masterPage == null)
            {
                throw new HttpException("Failed to create MasterPage instance for '" + masterPageFile + "'.");
            }

            if (contentTemplateCollection != null)
            {
                foreach (string templateName in contentTemplateCollection.Keys)
                {
                    if (masterPage.ContentTemplates [templateName] == null)
                    {
                        masterPage.ContentTemplates [templateName] = contentTemplateCollection[templateName];
                    }
                }
            }

            masterPage.Page = owner.Page;
            masterPage.InitializeAsUserControlInternal();

            List <string> placeholders = masterPage.placeholders;
            if (contentTemplateCollection != null && placeholders != null && placeholders.Count > 0)
            {
                foreach (string templateName in contentTemplateCollection.Keys)
                {
                    if (!placeholders.Contains(templateName.ToLowerInvariant()))
                    {
                        throw new HttpException(
                                  String.Format("Cannot find ContentPlaceHolder '{0}' in the master page '{1}'",
                                                templateName, masterPageFile));
                    }
                }
            }

            return(masterPage);
        }
		public static Type GetCompiledMasterType (string virtualPath, string inputFile, HttpContext context)
		{
			MasterPageParser mpp = new MasterPageParser (virtualPath, inputFile, context);
			return mpp.CompileIntoType ();
		}
 internal MasterPageCodeDomTreeGenerator(MasterPageParser parser) : base(parser) {
     _masterPageParser = parser;
 }
		public static MasterPage GetCompiledMasterInstance (string virtualPath, string inputFile, HttpContext context)
		{
			MasterPageParser mpp = new MasterPageParser (virtualPath, inputFile, context);
			return (MasterPage) mpp.GetCompiledInstance ();
		}
Example #5
0
		public MasterPageCompiler (MasterPageParser parser)
			: base (parser)
		{
			this.parser = parser;
		}