System.Web.UI.TemplateControlParser.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)
		{
			int cmp = String.Compare ("Register", directive, true, Helpers.InvariantCulture);
			if (cmp == 0) {
				string tagprefix = GetString (atts, "TagPrefix", null);
				if (tagprefix == null || tagprefix.Trim () == "")
					ThrowParseException ("No TagPrefix attribute found.");

				string ns = GetString (atts, "Namespace", null);
				string assembly = GetString (atts, "Assembly", null);

				if (ns == null && assembly != null)
					ThrowParseException ("Need a Namespace attribute with Assembly.");
				
				if (ns != null) {
					if (atts.Count != 0)
						ThrowParseException ("Unknown attribute: " + GetOneKey (atts));

					RegisterNamespace (tagprefix, ns, assembly);
					return;
				}

				string tagname = GetString (atts, "TagName", null);
				string src = GetString (atts, "Src", null);

				if (tagname == null && src != null)
					ThrowParseException ("Need a TagName attribute with Src.");

				if (tagname != null && src == null)
					ThrowParseException ("Need a Src attribute with TagName.");

				RegisterCustomControl (tagprefix, tagname, src);
				return;
			}

			cmp = String.Compare ("Reference", directive, true, Helpers.InvariantCulture);
			if (cmp == 0) {
				string vp = null;
				string page = GetString (atts, "Page", null);
				bool is_page = (page != null);

				if (is_page)
					vp = page;

				bool dupe = false;
				string control = GetString (atts, "Control", null);
				if (control != null)
					if (is_page)
						dupe = true;
					else
						vp = control;
				
				string virtualPath = GetString (atts, "VirtualPath", null);
				if (virtualPath != null)
					if (vp != null)
						dupe = true;
					else
						vp = virtualPath;
				
				if (vp == null)
					ThrowParseException ("Must provide one of the 'page', 'control' or 'virtualPath' attributes");
				
				if (dupe)
					ThrowParseException ("Only one attribute can be specified.");

				AddDependency (vp);
				
				Type ctype;
				ctype = BuildManager.GetCompiledType (vp);
				
				AddAssembly (ctype.Assembly, true);
				if (atts.Count != 0)
					ThrowParseException ("Unknown attribute: " + GetOneKey (atts));

				return;
			}

			base.AddDirective (directive, atts);
		}