2
0

AttributeCollection.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // System.Web.UI.AttributeCollection.cs
  3. //
  4. // Duncan Mak ([email protected])
  5. //
  6. // (C) Ximian, Inc.
  7. //
  8. using System;
  9. using System.Collections;
  10. namespace System.Web.UI {
  11. public sealed class AttributeCollection
  12. {
  13. StateBag bag;
  14. Hashtable list;
  15. public AttributeCollection (StateBag bag)
  16. {
  17. this.bag = bag;
  18. list = new Hashtable ();
  19. }
  20. public int Count {
  21. get { return list.Count; }
  22. }
  23. [MonoTODO]
  24. public CssStyleCollection CssStyle {
  25. get { return null; }
  26. }
  27. public string this [string key] {
  28. get { return list [key] as string; }
  29. set { list [key] = value; }
  30. }
  31. public ICollection Keys {
  32. get { return list.Keys; }
  33. }
  34. public void Add (string key, string value)
  35. {
  36. list.Add (key, value);
  37. }
  38. public void AddAttributes (HtmlTextWriter writer)
  39. {
  40. foreach (object key in list.Keys) {
  41. object value = list [key];
  42. writer.AddAttribute ((string) key, (string) value);
  43. }
  44. }
  45. public void Clear ()
  46. {
  47. list.Clear ();
  48. }
  49. public void Remove (string key)
  50. {
  51. list.Remove (key);
  52. }
  53. public void Render (HtmlTextWriter writer)
  54. {
  55. foreach (object key in list.Keys) {
  56. object value = list [key];
  57. writer.WriteAttribute ((string) key, (string) value);
  58. }
  59. }
  60. }
  61. }