2 // XPathMessageFilterTable.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2006 Novell, Inc. http://www.novell.com
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System
.Collections
;
30 using System
.Collections
.Generic
;
31 using System
.Reflection
;
32 using System
.Runtime
.Serialization
;
33 using System
.ServiceModel
.Channels
;
34 using System
.Xml
.XPath
;
35 using System
.ServiceModel
;
37 namespace System
.ServiceModel
.Dispatcher
40 public class XPathMessageFilterTable
<TFilterData
>
41 : IDictionary
<MessageFilter
,TFilterData
>,
42 IMessageFilterTable
<TFilterData
>,
44 ICollection
<KeyValuePair
<MessageFilter
,TFilterData
>>,
45 IEnumerable
<KeyValuePair
<MessageFilter
,TFilterData
>>
47 Dictionary
<MessageFilter
,TFilterData
> dict
48 = new Dictionary
<MessageFilter
,TFilterData
> ();
53 public XPathMessageFilterTable ()
58 public XPathMessageFilterTable (int quota
)
64 public int NodeQuota
{
66 set { quota = value; }
69 public TFilterData
this [MessageFilter key
] {
70 get { return dict [key]; }
71 set { dict [key] = value; }
75 get { return dict.Count; }
78 public bool IsReadOnly
{
82 public ICollection
<MessageFilter
> Keys
{
83 get { return dict.Keys; }
86 public ICollection
<TFilterData
> Values
{
87 get { return dict.Values; }
90 public void Add (KeyValuePair
<MessageFilter
,TFilterData
> item
)
92 dict
.Add (item
.Key
, item
.Value
);
96 public void Add (XPathMessageFilter filter
, TFilterData data
)
98 throw new NotImplementedException ();
101 public void Add (MessageFilter filter
, TFilterData data
)
103 dict
.Add (filter
, data
);
111 public bool Contains (KeyValuePair
<MessageFilter
,TFilterData
> item
)
113 return dict
.ContainsKey (item
.Key
) &&
114 dict
[item
.Key
].Equals (item
.Value
);
117 public bool ContainsKey (MessageFilter key
)
119 return dict
.ContainsKey (key
);
122 public void CopyTo (KeyValuePair
<MessageFilter
,TFilterData
> [] array
, int index
)
124 if (index
< 0 || dict
.Count
>= array
.Length
- index
)
125 throw new ArgumentOutOfRangeException ("index");
126 foreach (KeyValuePair
<MessageFilter
,TFilterData
> item
in dict
)
127 array
[index
++] = item
;
130 public IEnumerator
<KeyValuePair
<MessageFilter
,TFilterData
>> GetEnumerator ()
132 return dict
.GetEnumerator ();
135 IEnumerator IEnumerable
.GetEnumerator ()
137 return GetEnumerator ();
140 public bool GetMatchingFilter (Message message
, out MessageFilter result
)
142 throw new NotImplementedException ();
145 public bool GetMatchingFilter (MessageBuffer buffer
, out MessageFilter result
)
147 throw new NotImplementedException ();
150 public bool GetMatchingFilter (SeekableXPathNavigator navigator
, out MessageFilter filter
)
152 throw new NotImplementedException ();
155 public bool GetMatchingFilter (XPathNavigator navigator
, out MessageFilter filter
)
157 throw new NotImplementedException ();
160 public bool GetMatchingFilters (Message message
, ICollection
<MessageFilter
> results
)
162 throw new NotImplementedException ();
165 public bool GetMatchingFilters (MessageBuffer buffer
, ICollection
<MessageFilter
> results
)
167 throw new NotImplementedException ();
170 public bool GetMatchingFilters (SeekableXPathNavigator navigator
, ICollection
<MessageFilter
> results
)
172 throw new NotImplementedException ();
175 public bool GetMatchingFilters (XPathNavigator navigator
, ICollection
<MessageFilter
> results
)
177 throw new NotImplementedException ();
180 public bool GetMatchingValue (Message message
, out TFilterData data
)
182 throw new NotImplementedException ();
185 public bool GetMatchingValue (MessageBuffer buffer
, out TFilterData data
)
187 throw new NotImplementedException ();
190 public bool GetMatchingValue (SeekableXPathNavigator navigator
, out TFilterData data
)
192 throw new NotImplementedException ();
195 public bool GetMatchingValue (XPathNavigator navigator
, out TFilterData data
)
197 throw new NotImplementedException ();
200 public bool GetMatchingValues (Message message
, ICollection
<TFilterData
> results
)
202 throw new NotImplementedException ();
205 public bool GetMatchingValues (MessageBuffer buffer
, ICollection
<TFilterData
> results
)
207 throw new NotImplementedException ();
210 public bool GetMatchingValues (SeekableXPathNavigator navigator
, ICollection
<TFilterData
> results
)
212 throw new NotImplementedException ();
215 public bool GetMatchingValues (XPathNavigator navigator
, ICollection
<TFilterData
> results
)
217 throw new NotImplementedException ();
220 public bool Remove (KeyValuePair
<MessageFilter
,TFilterData
> item
)
222 if (dict
.ContainsKey (item
.Key
) && dict
[item
.Key
].Equals (item
.Value
)) {
223 dict
.Remove (item
.Key
);
229 public bool Remove (XPathMessageFilter filter
)
231 return dict
.Remove (filter
);
234 public bool Remove (MessageFilter filter
)
236 return Remove ((XPathMessageFilter
) filter
);
239 static Exception trim_to_size_error
;
241 public void TrimToSize ()
243 // This is the documented behavior: throws NIE.
244 if (trim_to_size_error
== null)
245 trim_to_size_error
= new NotImplementedException ();
246 throw trim_to_size_error
;
249 public bool TryGetValue (MessageFilter filter
, out TFilterData data
)
251 return dict
.TryGetValue (filter
, out data
);