System.Web.UI.PageParser.AddDirective C# (CSharp) Method

AddDirective() private method

private AddDirective ( string directive, IDictionary atts ) : void
directive string
atts IDictionary
return void
		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);
		}