2 // System.Web.Configuration.HandlerFactoryConfiguration
5 // Patrik Torstensson (ptorsten@hotmail.com)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
8 // (C) 2002 Ximian, Inc (http://www.ximian.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Collections
;
34 namespace System
.Web
.Configuration
36 class HandlerFactoryConfiguration
42 public HandlerFactoryConfiguration () : this (null)
46 public HandlerFactoryConfiguration (HandlerFactoryConfiguration parent
)
49 mappings
= new ArrayList (parent
.mappings
);
51 mappings
= new ArrayList ();
53 _cache
= Hashtable
.Synchronized(new Hashtable());
54 ownIndex
= mappings
.Count
;
57 public void Add (HandlerItem mapping
)
59 mappings
.Add (mapping
);
62 public HandlerItem
Remove (string verb
, string path
)
64 int i
= GetIndex (verb
, path
);
68 HandlerItem item
= (HandlerItem
) mappings
[i
];
69 mappings
.RemoveAt (i
);
70 if (_cache
.ContainsKey(verb
+"+"+path
))
71 _cache
.Remove(verb
+"+"+path
);
81 public HandlerItem
FindHandler (string verb
, string path
)
83 int i
= GetIndex (verb
, path
);
87 return (HandlerItem
) mappings
[i
];
90 int GetIndex (string verb
, string path
)
92 string cahceKey
= verb
+"+"+path
;
93 object answer
= _cache
[cahceKey
];
96 int end
= mappings
.Count
;
98 for (int i
= ownIndex
; i
< end
; i
++) {
99 HandlerItem item
= (HandlerItem
) mappings
[i
];
100 if (item
.IsMatch (verb
, path
))
102 _cache
[cahceKey
] = i
;
109 for (int i
= 0; i
< end
; i
++) {
110 HandlerItem item
= (HandlerItem
) mappings
[i
];
111 if (item
.IsMatch (verb
, path
))
113 _cache
[cahceKey
] = i
;
117 _cache
[cahceKey
] = -1;