void HandleDirective(WebFormsDirective directive, List <Error> errors)
        {
            switch (directive.Name.Name.ToLowerInvariant())
            {
            case "page":
                MasterPageFile = GetAttributeValueCI(directive.Attributes, "masterpagefile");
                SetSubtype(WebSubtype.WebForm, directive, errors);
                break;

            case "control":
                SetSubtype(WebSubtype.WebControl, directive, errors);
                break;

            case "webservice":
                SetSubtype(WebSubtype.WebService, directive, errors);
                break;

            case "webhandler":
                SetSubtype(WebSubtype.WebHandler, directive, errors);
                break;

            case "application":
                SetSubtype(WebSubtype.Global, directive, errors);
                break;

            case "master":
                SetSubtype(WebSubtype.MasterPage, directive, errors);
                break;

            case "mastertype":
                if (MasterPageTypeVPath != null || MasterPageTypeName != null)
                {
                    errors.Add(new Error(ErrorType.Error, "Unexpected second mastertype directive", directive.Region));
                    return;
                }
                MasterPageTypeName  = GetAttributeValueCI(directive.Attributes, "typename");
                MasterPageTypeVPath = GetAttributeValueCI(directive.Attributes, "virtualpath");
                if (string.IsNullOrEmpty(MasterPageTypeName) == string.IsNullOrEmpty(MasterPageTypeVPath))
                {
                    errors.Add(new Error(
                                   ErrorType.Error,
                                   "Mastertype directive must have non-empty 'typename' or 'virtualpath' attribute",
                                   directive.Region
                                   )
                               );
                }
                break;

            case "register":
                string tagPrefix = GetAttributeValueCI(directive.Attributes, "tagprefix");
                string tagName   = GetAttributeValueCI(directive.Attributes, "tagname");
                string src       = GetAttributeValueCI(directive.Attributes, "src");
                string nspace    = GetAttributeValueCI(directive.Attributes, "namespace");
                string assembly  = GetAttributeValueCI(directive.Attributes, "assembly");
                if (!string.IsNullOrEmpty(tagPrefix))
                {
                    if (!string.IsNullOrEmpty(tagName) && !string.IsNullOrEmpty(src))
                    {
                        registeredTags.Add(new ControlRegisterDirective(tagPrefix, tagName, src));
                    }
                    else if (!string.IsNullOrEmpty(nspace) && !string.IsNullOrEmpty(assembly))
                    {
                        registeredTags.Add(new AssemblyRegisterDirective(tagPrefix, nspace, assembly));
                    }
                }
                break;

            case "assembly":
                var assm = new AssemblyDirective(
                    GetAttributeValueCI(directive.Attributes, "name"),
                    GetAttributeValueCI(directive.Attributes, "src"));
                if (assm.IsValid())
                {
                    assemblies.Add(assm);
                }
                else
                {
                    errors.Add(new Error(
                                   ErrorType.Error,
                                   "Assembly directive must have non-empty 'name' or 'src' attribute",
                                   directive.Region
                                   )
                               );
                }
                break;

            case "import":
                string ns = GetAttributeValueCI(directive.Attributes, "namespace");
                if (!string.IsNullOrEmpty(ns))
                {
                    imports.Add(ns);
                }
                else
                {
                    errors.Add(new Error(
                                   ErrorType.Error,
                                   "Import directive must have non-empty 'namespace' attribute",
                                   directive.Region
                                   )
                               );
                }
                break;

            case "implements":
                string interf = GetAttributeValueCI(directive.Attributes, "interface");
                if (!string.IsNullOrEmpty(interf))
                {
                    implements.Add(interf);
                }
                else
                {
                    errors.Add(new Error(
                                   ErrorType.Error,
                                   "Implements directive must have non-empty 'interface' attribute",
                                   directive.Region
                                   )
                               );
                }
                break;

            default:
                break;
            }
        }
		void HandleDirective (WebFormsDirective directive, List<Error> errors)
		{
			switch (directive.Name.Name.ToLowerInvariant ()) {
			case "page":
				MasterPageFile = GetAttributeValueCI (directive.Attributes, "masterpagefile");
				SetSubtype (WebSubtype.WebForm, directive, errors);
				break;
			case "control":
				SetSubtype (WebSubtype.WebControl, directive, errors);
				break;
			case "webservice":
				SetSubtype (WebSubtype.WebService, directive, errors);
				break;
			case "webhandler":
				SetSubtype (WebSubtype.WebHandler, directive, errors);
				break;
			case "application":
				SetSubtype (WebSubtype.Global, directive, errors);
				break;
			case "master":
				SetSubtype (WebSubtype.MasterPage, directive, errors);
				break;
			case "mastertype":
				if (MasterPageTypeVPath != null || MasterPageTypeName != null) {
					errors.Add (new Error (ErrorType.Error, GettextCatalog.GetString ("Unexpected second mastertype directive"), directive.Region));
					return;
				}
				MasterPageTypeName = GetAttributeValueCI (directive.Attributes, "typename");
				MasterPageTypeVPath = GetAttributeValueCI (directive.Attributes, "virtualpath");
				if (string.IsNullOrEmpty (MasterPageTypeName) == string.IsNullOrEmpty (MasterPageTypeVPath))
					errors.Add (new Error (
						ErrorType.Error,
						GettextCatalog.GetString ("Mastertype directive must have non-empty 'typename' or 'virtualpath' attribute"),
						directive.Region
					)
					);
				break;
			case "register":
				string tagPrefix = GetAttributeValueCI (directive.Attributes, "tagprefix");
				string tagName = GetAttributeValueCI (directive.Attributes, "tagname");
				string src = GetAttributeValueCI (directive.Attributes, "src");
				string nspace = GetAttributeValueCI (directive.Attributes, "namespace");
				string assembly = GetAttributeValueCI (directive.Attributes, "assembly");
				if (!string.IsNullOrEmpty (tagPrefix)) {
					if (!string.IsNullOrEmpty (tagName) && !string.IsNullOrEmpty (src))
						registeredTags.Add (new ControlRegisterDirective (tagPrefix, tagName, src));
					else if (!string.IsNullOrEmpty (nspace) && !string.IsNullOrEmpty (assembly))
						registeredTags.Add (new AssemblyRegisterDirective (tagPrefix, nspace, assembly));
				}
				break;
			case "assembly":
				var assm = new AssemblyDirective (
					GetAttributeValueCI (directive.Attributes, "name"),
					GetAttributeValueCI (directive.Attributes, "src"));
				if (assm.IsValid ())
					assemblies.Add (assm);
				else
					errors.Add (new Error (
						ErrorType.Error,
						GettextCatalog.GetString ("Assembly directive must have non-empty 'name' or 'src' attribute"),
						directive.Region
					)
					);
				break;
			case "import":
				string ns = GetAttributeValueCI (directive.Attributes, "namespace");
				if (!string.IsNullOrEmpty (ns))
					imports.Add (ns);
				else
					errors.Add (new Error (
						ErrorType.Error,
						GettextCatalog.GetString ("Import directive must have non-empty 'namespace' attribute"),
						directive.Region
					)
					);
				break;
			case "implements":
				string interf = GetAttributeValueCI (directive.Attributes, "interface");
				if (!string.IsNullOrEmpty (interf))
					implements.Add (interf);
				else
					errors.Add (new Error (
						ErrorType.Error,
						GettextCatalog.GetString ("Implements directive must have non-empty 'interface' attribute"),
						directive.Region
					)
					);
				break;
			default:
				break;
			}
		}