HandlerFactoryConfiguration.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // System.Web.Configuration.HandlerFactoryConfiguration
  3. //
  4. // Authors:
  5. // Patrik Torstensson ([email protected])
  6. // Gonzalo Paniagua Javier ([email protected])
  7. //
  8. // (C) 2002 Ximian, Inc (http://www.ximian.com)
  9. //
  10. using System.Collections;
  11. namespace System.Web.Configuration
  12. {
  13. class HandlerFactoryConfiguration
  14. {
  15. ArrayList mappings;
  16. public HandlerFactoryConfiguration () : this (null)
  17. {
  18. }
  19. public HandlerFactoryConfiguration (HandlerFactoryConfiguration parent)
  20. {
  21. if (parent != null)
  22. mappings = new ArrayList (parent.mappings);
  23. else
  24. mappings = new ArrayList ();
  25. }
  26. public void Add (HandlerItem mapping)
  27. {
  28. mappings.Add (mapping);
  29. }
  30. public HandlerItem Remove (string verb, string path)
  31. {
  32. int i = GetIndex (verb, path);
  33. if (i == -1)
  34. return null;
  35. HandlerItem item = (HandlerItem) mappings [i];
  36. mappings.RemoveAt (i);
  37. return item;
  38. }
  39. public void Clear ()
  40. {
  41. mappings.Clear ();
  42. }
  43. public HandlerItem FindHandler (string verb, string path)
  44. {
  45. int i = GetIndex (verb, path);
  46. if (i == -1)
  47. return null;
  48. return (HandlerItem) mappings [i];
  49. }
  50. int GetIndex (string verb, string path)
  51. {
  52. int end = mappings.Count;
  53. for (int i = 0; i < end; i++) {
  54. HandlerItem item = (HandlerItem) mappings [i];
  55. if (item.IsMatch (verb, path))
  56. return i;
  57. }
  58. return -1;
  59. }
  60. }
  61. }