internal static PageParserFilter Create(PagesSection pagesConfig, System.Web.VirtualPath virtualPath, TemplateParser parser)
        {
            PageParserFilter filter = pagesConfig.CreateControlTypeFilter();

            if (filter != null)
            {
                filter.InitializeInternal(virtualPath, parser);
            }
            return(filter);
        }
        internal override void AddDirective(string directive, IDictionary atts)
        {
            if (String.Compare("MasterType", directive, StringComparison.OrdinalIgnoreCase) == 0)
            {
                PageParserFilter pfilter = PageParserFilter;
                if (pfilter != null)
                {
                    pfilter.PreprocessDirective(directive.ToLowerInvariant(), atts);
                }

                string type = GetString(atts, "TypeName", null);
                if (type != null)
                {
                    masterType = LoadType(type);
                    if (masterType == null)
                    {
                        ThrowParseException("Could not load type '" + type + "'.");
                    }
                }
                else
                {
                    string path = GetString(atts, "VirtualPath", null);
                    if (!String.IsNullOrEmpty(path))
                    {
                        var vpp = HostingEnvironment.VirtualPathProvider;
                        if (!vpp.FileExists(path))
                        {
                            ThrowParseFileNotFound(path);
                        }

                        path = vpp.CombineVirtualPaths(VirtualPath.Absolute, VirtualPathUtility.ToAbsolute(path));
                        masterTypeVirtualPath = path;
                        AddDependency(path);
                    }
                    else
                    {
                        ThrowParseException("The MasterType directive must have either a TypeName or a VirtualPath attribute.");
                    }
                }
                if (masterType != null)
                {
                    AddAssembly(masterType.Assembly, true);
                }
            }
            else
            {
                base.AddDirective(directive, atts);
            }
        }
示例#3
0
		internal override void AddDirective (string directive, IDictionary atts)
		{
			bool isMasterType = String.Compare ("MasterType", directive, StringComparison.OrdinalIgnoreCase) == 0;
			bool isPreviousPageType = isMasterType ? false : String.Compare ("PreviousPageType", directive,
											 StringComparison.OrdinalIgnoreCase) == 0;

			string typeName = null;
			string virtualPath = null;
			Type type = null;
			
			if (isMasterType || isPreviousPageType) {
				PageParserFilter pfilter = PageParserFilter;
				if (pfilter != null)
					pfilter.PreprocessDirective (directive.ToLowerInvariant (), atts);
				
				typeName = GetString (atts, "TypeName", null);
				virtualPath = GetString (atts, "VirtualPath", null);

				if (typeName != null && virtualPath != null)
					ThrowParseException (
						String.Format ("The '{0}' directive must have exactly one attribute: TypeName or VirtualPath", directive));
				if (typeName != null) {
					type = LoadType (typeName);
					if (type == null)
						ThrowParseException (String.Format ("Could not load type '{0}'.", typeName));
					if (isMasterType)
						masterType = type;
					else
						previousPageType = type;
				} else if (!String.IsNullOrEmpty (virtualPath)) {
					if (!HostingEnvironment.VirtualPathProvider.FileExists (virtualPath))
						ThrowParseFileNotFound (virtualPath);

					AddDependency (virtualPath);
					if (isMasterType)
						masterVirtualPath = virtualPath;
					else
						previousPageVirtualPath = virtualPath;
				} else
					ThrowParseException (String.Format ("The {0} directive must have either a TypeName or a VirtualPath attribute.", directive));

				if (type != null)
					AddAssembly (type.Assembly, true);
			} else
				base.AddDirective (directive, atts);
		}
示例#4
0
    // Get default settings from config
    internal virtual void ProcessConfigSettings() {
        if (_compConfig != null) {
            flags[useExplicit] = _compConfig.Explicit;
            flags[strict] = _compConfig.Strict;
        }

        if (PagesConfig != null) {
            _namespaceEntries = PagesConfig.Namespaces.NamespaceEntries;

            // Clone it so we don't modify the config settings
            if (_namespaceEntries != null)
                _namespaceEntries = (Hashtable) _namespaceEntries.Clone();

            if (!flags[ignoreParserFilter]) {
                // Check if a filter is registered, and if so initialize it
                _pageParserFilter = PageParserFilter.Create(PagesConfig, CurrentVirtualPath, this);
            }
        }
    }