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 GetMatchingFilters (Message message, ICollection<MessageFilter> results)
152 throw new NotImplementedException ();
155 public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
157 throw new NotImplementedException ();
160 public bool GetMatchingValue (Message message, out TFilterData data)
162 throw new NotImplementedException ();
165 public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
167 throw new NotImplementedException ();
170 public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
172 throw new NotImplementedException ();
175 public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
177 throw new NotImplementedException ();
180 public bool Remove (KeyValuePair<MessageFilter,TFilterData> item)
182 if (dict.ContainsKey (item.Key) && dict [item.Key].Equals (item.Value)) {
183 dict.Remove (item.Key);
189 public bool Remove (XPathMessageFilter filter)
191 throw new NotImplementedException ();
194 public bool Remove (MessageFilter filter)
196 return dict.Remove (filter);
199 public bool TryGetValue (MessageFilter filter, out TFilterData filterData)
201 if (dict.ContainsKey (filter)) {
202 filterData = dict [filter];
205 filterData = default (TFilterData);
211 public void TrimToSize ()
213 throw new NotImplementedException ();