2 // System.Web.UI.AttributeCollection.cs
5 // Duncan Mak (duncan@ximian.com)
6 // Gonzalo Paniagua (gonzalo@ximian.com)
8 // (C) 2002 Ximian, Inc. (http://www.ximian.com
12 using System.Collections;
14 namespace System.Web.UI {
16 public sealed class AttributeCollection
19 private CssStyleCollection styleCollection;
21 public AttributeCollection (StateBag bag)
27 get { return bag.Count; }
30 public CssStyleCollection CssStyle {
32 if (styleCollection == null)
33 styleCollection = new CssStyleCollection (bag);
34 return styleCollection;
38 public string this [string key] {
39 get { return bag [key] as string; }
41 set { bag.Add (key, value); }
44 public ICollection Keys {
45 get { return bag.Keys; }
48 public void Add (string key, string value)
50 if (styleCollection != null && 0 == String.Compare (key, "style", true))
51 styleCollection.FillStyle (value);
56 public void AddAttributes (HtmlTextWriter writer)
58 foreach (string key in bag.Keys) {
59 string value = bag [key] as string;
60 writer.AddAttribute (key, value);
69 public void Remove (string key)
74 public void Render (HtmlTextWriter writer)
76 foreach (string key in bag.Keys) {
77 string value = bag [key] as string;
79 writer.WriteAttribute (key, value);