(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Web / System.Web.Configuration / HandlerFactoryConfiguration.cs
blob68a80c8019d3e370ae0312bbbc663e9c973697cd
1 //
2 // System.Web.Configuration.HandlerFactoryConfiguration
3 //
4 // Authors:
5 // Patrik Torstensson (ptorsten@hotmail.com)
6 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 //
8 // (C) 2002 Ximian, Inc (http://www.ximian.com)
9 //
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:
19 //
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 //
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
38 ArrayList mappings;
39 Hashtable _cache;
40 int ownIndex;
42 public HandlerFactoryConfiguration () : this (null)
46 public HandlerFactoryConfiguration (HandlerFactoryConfiguration parent)
48 if (parent != null)
49 mappings = new ArrayList (parent.mappings);
50 else
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);
65 if (i == -1)
66 return null;
68 HandlerItem item = (HandlerItem) mappings [i];
69 mappings.RemoveAt (i);
70 if (_cache.ContainsKey(verb+"+"+path))
71 _cache.Remove(verb+"+"+path);
72 return item;
75 public void Clear ()
77 mappings.Clear ();
78 _cache.Clear();
81 public HandlerItem FindHandler (string verb, string path)
83 int i = GetIndex (verb, path);
84 if (i == -1)
85 return null;
87 return (HandlerItem) mappings [i];
90 int GetIndex (string verb, string path)
92 string cahceKey = verb+"+"+path;
93 object answer = _cache[cahceKey];
94 if (answer != null)
95 return (int)answer;
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;
103 return i;
107 // parent mappings
108 end = ownIndex;
109 for (int i = 0; i < end; i++) {
110 HandlerItem item = (HandlerItem) mappings [i];
111 if (item.IsMatch (verb, path))
113 _cache[cahceKey] = i;
114 return i;
117 _cache[cahceKey] = -1;
118 return -1;