public override void Visit (DirectiveNode node)
			{
				var atts = node.Attributes;
				
				switch (node.Name.ToLowerInvariant ()) {
				case "page":
					SetSubtype (WebSubtype.WebForm, node);
					if (atts == null)
						return;
					info.MasterPageFile = atts ["masterpagefile"] as string;
					break;
				case "control":
					SetSubtype (WebSubtype.WebControl, node);
					break;
				case "webservice":
					SetSubtype (WebSubtype.WebService, node);
					break;
				case "webhandler":
					SetSubtype (WebSubtype.WebHandler, node);
					break;
				case "application":
					SetSubtype (WebSubtype.Global, node);
					break;
				case "master":
					SetSubtype (WebSubtype.MasterPage, node);
					break;
				case "mastertype":
					if (info.MasterPageTypeVPath != null || info.MasterPageTypeName != null) {
						Add (ErrorType.Error, node, "Unexpected second mastertype directive", node.Name);
						return;
					}
					if (atts == null)
						return;
					info.MasterPageTypeName = atts["typename"] as string;
					info.MasterPageTypeVPath = atts["virtualpath"] as string;
					if (string.IsNullOrEmpty (info.MasterPageTypeName) == string.IsNullOrEmpty (info.MasterPageTypeVPath))
						Add (ErrorType.Error, node, "Mastertype directive must have non-empty 'typename' or 'virtualpath' attribute");
					break;
				case "register":
					if (atts == null)
						return;
					if (atts ["TagPrefix"] != null) {
						if ((atts ["TagName"] != null) && (atts ["Src"] != null))
							info.registeredTags.Add (new ControlRegisterDirective (node));
						else if ((atts ["Namespace"] != null) && (atts ["Assembly"] != null))
							info.registeredTags.Add (new AssemblyRegisterDirective (node));
					}
					break;
				case "assembly":
					if (atts == null)
						return;
					var assembly = new AssemblyDirective (atts ["name"] as string, atts ["src"] as string);
					if (assembly.IsValid ())
						info.assemblies.Add (assembly);
					else
						Add (ErrorType.Error, node, "Assembly directive must have non-empty 'name' or 'src' attribute");
					break;
				case "import":
					if (atts == null)
						return;
					var ns = atts ["namespace"] as string;
					if (!string.IsNullOrEmpty (ns))
						info.imports.Add (ns);
					else
						Add (ErrorType.Error, node, "Import directive must have non-empty 'namespace' attribute");
					break;
				case "implements":
					if (atts == null)
						return;
					var interf = atts ["interface"] as string;
					if (!string.IsNullOrEmpty (interf))
						info.implements.Add (interf);
					else
						Add (ErrorType.Error, node, "Implements directive must have non-empty 'interface' attribute");
					break;
				default:
					break;
				}
			}
Exemplo n.º 2
0
		void HandleDirective (AspNetDirective 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;
			}
		}
Exemplo n.º 3
0
        void HandleDirective(AspNetDirective 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;
            }
        }
            public override void Visit(DirectiveNode node)
            {
                var atts = node.Attributes;

                switch (node.Name.ToLowerInvariant())
                {
                case "page":
                    SetSubtype(WebSubtype.WebForm, node);
                    if (atts == null)
                    {
                        return;
                    }
                    info.MasterPageFile = atts ["masterpagefile"] as string;
                    break;

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

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

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

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

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

                case "mastertype":
                    if (info.MasterPageTypeVPath != null || info.MasterPageTypeName != null)
                    {
                        Add(ErrorType.Error, node, "Unexpected second mastertype directive", node.Name);
                        return;
                    }
                    if (atts == null)
                    {
                        return;
                    }
                    info.MasterPageTypeName  = atts["typename"] as string;
                    info.MasterPageTypeVPath = atts["virtualpath"] as string;
                    if (string.IsNullOrEmpty(info.MasterPageTypeName) == string.IsNullOrEmpty(info.MasterPageTypeVPath))
                    {
                        Add(ErrorType.Error, node, "Mastertype directive must have non-empty 'typename' or 'virtualpath' attribute");
                    }
                    break;

                case "register":
                    if (atts == null)
                    {
                        return;
                    }
                    if (atts ["TagPrefix"] != null)
                    {
                        if ((atts ["TagName"] != null) && (atts ["Src"] != null))
                        {
                            info.registeredTags.Add(new ControlRegisterDirective(node));
                        }
                        else if ((atts ["Namespace"] != null) && (atts ["Assembly"] != null))
                        {
                            info.registeredTags.Add(new AssemblyRegisterDirective(node));
                        }
                    }
                    break;

                case "assembly":
                    if (atts == null)
                    {
                        return;
                    }
                    var assembly = new AssemblyDirective(atts ["name"] as string, atts ["src"] as string);
                    if (assembly.IsValid())
                    {
                        info.assemblies.Add(assembly);
                    }
                    else
                    {
                        Add(ErrorType.Error, node, "Assembly directive must have non-empty 'name' or 'src' attribute");
                    }
                    break;

                case "import":
                    if (atts == null)
                    {
                        return;
                    }
                    var ns = atts ["namespace"] as string;
                    if (!string.IsNullOrEmpty(ns))
                    {
                        info.imports.Add(ns);
                    }
                    else
                    {
                        Add(ErrorType.Error, node, "Import directive must have non-empty 'namespace' attribute");
                    }
                    break;

                case "implements":
                    if (atts == null)
                    {
                        return;
                    }
                    var interf = atts ["interface"] as string;
                    if (!string.IsNullOrEmpty(interf))
                    {
                        info.implements.Add(interf);
                    }
                    else
                    {
                        Add(ErrorType.Error, node, "Implements directive must have non-empty 'interface' attribute");
                    }
                    break;

                default:
                    break;
                }
            }