2 // System.ServiceModel.ActionMessageFilterTable.cs
4 // Author: Duncan Mak (duncan@novell.com)
6 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
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:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
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.
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
{
38 internal class ActionMessageFilterTable
<TFilterData
>
39 : IMessageFilterTable
<TFilterData
>,
40 IDictionary
<MessageFilter
,TFilterData
>,
41 ICollection
<KeyValuePair
<MessageFilter
, TFilterData
>>,
42 IEnumerable
<KeyValuePair
<MessageFilter
,TFilterData
>>,
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
);
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
)
135 throw new ArgumentNullException ("filter is null.");
137 return table
.Remove (filter
);
140 public bool Remove (MessageFilter filter
)
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
];
165 data
= default (TFilterData
);
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; }