2010-04-06 Jb Evain <jbevain@novell.com>
[mcs.git] / class / System.ServiceModel / System.ServiceModel.Dispatcher / ActionMessageFilterTable.cs
blob02b74b6cb4853b8f295f15a84f6d36d52c25c14c
1 //
2 // System.ServiceModel.ActionMessageFilterTable.cs
3 //
4 // Author: Duncan Mak (duncan@novell.com)
5 //
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Runtime.Serialization;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
35 namespace System.ServiceModel.Dispatcher {
37 [DataContract]
38 internal class ActionMessageFilterTable<TFilterData>
39 : IMessageFilterTable<TFilterData>,
40 IDictionary<MessageFilter,TFilterData>,
41 ICollection<KeyValuePair<MessageFilter, TFilterData>>,
42 IEnumerable<KeyValuePair<MessageFilter,TFilterData>>,
43 IEnumerable
45 Dictionary<MessageFilter, TFilterData> table;
47 public ActionMessageFilterTable ()
49 table = new Dictionary<MessageFilter, TFilterData> ();
52 public void Add (KeyValuePair<MessageFilter, TFilterData> item)
54 table.Add (item.Key, item.Value);
57 public void Add (ActionMessageFilter filter, TFilterData data)
59 table.Add (filter, data);
62 public void Add (MessageFilter filter, TFilterData data)
64 table.Add (filter, data);
67 public void Clear ()
69 table.Clear ();
72 public bool Contains (KeyValuePair<MessageFilter, TFilterData> item)
74 return table.ContainsKey (item.Key);
77 public bool ContainsKey (MessageFilter filter)
79 return table.ContainsKey (filter);
82 public void CopyTo (KeyValuePair<MessageFilter, TFilterData> [] array, int index)
84 ((ICollection<KeyValuePair<MessageFilter, TFilterData>>) table).CopyTo (array, index);
87 public IEnumerator<KeyValuePair<MessageFilter, TFilterData>> GetEnumerator ()
89 return ((ICollection<KeyValuePair<MessageFilter, TFilterData>>) table).GetEnumerator ();
92 public bool GetMatchingFilter (Message message, out MessageFilter result)
94 throw new NotImplementedException ();
97 public bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result)
99 throw new NotImplementedException ();
102 public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
104 throw new NotImplementedException ();
107 public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
109 throw new NotImplementedException ();
112 public bool GetMatchingValue (Message message, out TFilterData data)
114 throw new NotImplementedException ();
117 public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
119 throw new NotImplementedException ();
122 public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
124 throw new NotImplementedException ();
127 public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
129 throw new NotImplementedException ();
132 public bool Remove (ActionMessageFilter filter)
134 if (filter == null)
135 throw new ArgumentNullException ("filter is null.");
137 return table.Remove (filter);
140 public bool Remove (MessageFilter filter)
142 if (filter == null)
143 throw new ArgumentNullException ("filter is null.");
145 return table.Remove (filter);
148 public bool Remove (KeyValuePair<MessageFilter, TFilterData> item)
150 return table.Remove (item.Key);
153 IEnumerator IEnumerable.GetEnumerator ()
155 return table.GetEnumerator ();
158 public bool TryGetValue (MessageFilter filter, out TFilterData data)
160 if (table.ContainsKey (filter)){
161 data = table [filter];
162 return true;
165 data = default (TFilterData);
166 return false;
169 public int Count { get { return table.Count; }}
171 public bool IsReadOnly { get { return false; }}
173 public TFilterData this [MessageFilter filter] {
174 get { return table [filter]; }
175 set { table [filter] = value; }
178 public ICollection<MessageFilter> Keys {
179 get { return table.Keys; }
182 public ICollection<TFilterData> Values {
183 get { return table.Values; }