System.Web.Compilation.AspGenerator.CheckForDuplicateIds C# (CSharp) Method

CheckForDuplicateIds() private method

private CheckForDuplicateIds ( ControlBuilder root, Stack scopes ) : void
root System.Web.UI.ControlBuilder
scopes System.Collections.Stack
return void
		void CheckForDuplicateIds (ControlBuilder root, Stack scopes)
		{
			if (root == null)
				return;
			
			if (scopes == null)
				scopes = new Stack ();			

			Dictionary <string, bool> ids;
			
			if (scopes.Count == 0 || root.IsNamingContainer) {
				ids = new Dictionary <string, bool> (StringComparer.Ordinal);
				scopes.Push (ids);
			} else {
				ids = scopes.Peek () as Dictionary <string, bool>;
			}
			
			if (ids == null)
				return;

			ControlBuilder cb;
			string id;
			ArrayList children = root.Children;
			if (children != null) {
				foreach (object o in children) {
					cb = o as ControlBuilder;
					if (cb == null)
						continue;

					id = cb.ID;
					if (id == null || id.Length == 0)
						continue;
				
					if (ids.ContainsKey (id))
						throw new ParseException (cb.Location, "Id '" + id + "' is already used by another control.");

					ids.Add (id, true);
					CheckForDuplicateIds (cb, scopes);
				}
			}
		}