Turn eval test into normal test case
[mono.git] / mcs / class / System.ServiceModel / System.ServiceModel.Dispatcher / EndpointAddressMessageFilterTable.cs
1 //
2 // EndpointAddressMessageFilterTable.cs
3 //
4 // Author:
5 //      Atsushi Enomoto <atsushi@ximian.com>
6 //
7 // Copyright (C) 2006 Novell, Inc.  http://www.novell.com
8 //
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:
16 // 
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 // 
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.
27 //
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
34
35 namespace System.ServiceModel.Dispatcher
36 {
37         internal class EndpointAddressMessageFilterTable<TFilterData>
38                 : IDictionary<MessageFilter,TFilterData>,
39                   IMessageFilterTable<TFilterData>,
40                   IEnumerable,
41                   ICollection<KeyValuePair<MessageFilter,TFilterData>>,
42                   IEnumerable<KeyValuePair<MessageFilter,TFilterData>>
43         {
44                 Dictionary<MessageFilter,TFilterData> dict
45                         = new Dictionary<MessageFilter,TFilterData> ();
46
47                 public EndpointAddressMessageFilterTable ()
48                 {
49                 }
50
51                 public TFilterData this [MessageFilter key] {
52                         get { return dict [key]; }
53                         set { dict [key] = value; }
54                 }
55
56                 public int Count {
57                         get { return dict.Count; }
58                 }
59
60                 public bool IsReadOnly {
61                         get { return false; }
62                 }
63
64                 public ICollection<MessageFilter> Keys {
65                         get { return dict.Keys; }
66                 }
67
68                 public ICollection<TFilterData> Values {
69                         get { return dict.Values; }
70                 }
71
72                 public void Add (KeyValuePair<MessageFilter,TFilterData> item)
73                 {
74                         dict.Add (item.Key, item.Value);
75                 }
76
77                 [MonoTODO]
78                 public void Add (EndpointAddressMessageFilter filter, TFilterData data)
79                 {
80                         throw new NotImplementedException ();
81                 }
82
83                 public void Add (MessageFilter filter, TFilterData data)
84                 {
85                         dict.Add (filter, data);
86                 }
87
88                 public void Clear ()
89                 {
90                         dict.Clear ();
91                 }
92
93                 public bool Contains (KeyValuePair<MessageFilter,TFilterData> item)
94                 {
95                         return dict.ContainsKey (item.Key) &&
96                                 dict [item.Key].Equals (item.Value);
97                 }
98
99                 public bool ContainsKey (MessageFilter key)
100                 {
101                         return dict.ContainsKey (key);
102                 }
103
104                 public void CopyTo (KeyValuePair<MessageFilter,TFilterData> [] array, int index)
105                 {
106                         if (index < 0 || dict.Count >= array.Length - index)
107                                 throw new ArgumentOutOfRangeException ("index");
108                         foreach (KeyValuePair<MessageFilter,TFilterData> item in dict)
109                                 array [index++] = item;
110                 }
111
112                 public IEnumerator<KeyValuePair<MessageFilter,TFilterData>> GetEnumerator ()
113                 {
114                         return dict.GetEnumerator ();
115                 }
116
117                 IEnumerator IEnumerable.GetEnumerator ()
118                 {
119                         return GetEnumerator ();
120                 }
121
122                 public bool GetMatchingFilter (Message message, out MessageFilter result)
123                 {
124                         throw new NotImplementedException ();
125                 }
126
127                 public bool GetMatchingFilter (MessageBuffer buffer, out MessageFilter result)
128                 {
129                         throw new NotImplementedException ();
130                 }
131
132                 public bool GetMatchingFilters (Message message, ICollection<MessageFilter> results)
133                 {
134                         throw new NotImplementedException ();
135                 }
136
137                 public bool GetMatchingFilters (MessageBuffer buffer, ICollection<MessageFilter> results)
138                 {
139                         throw new NotImplementedException ();
140                 }
141
142                 public bool GetMatchingValue (Message message, out TFilterData data)
143                 {
144                         throw new NotImplementedException ();
145                 }
146
147                 public bool GetMatchingValue (MessageBuffer buffer, out TFilterData data)
148                 {
149                         throw new NotImplementedException ();
150                 }
151
152                 public bool GetMatchingValues (Message message, ICollection<TFilterData> results)
153                 {
154                         throw new NotImplementedException ();
155                 }
156
157                 public bool GetMatchingValues (MessageBuffer buffer, ICollection<TFilterData> results)
158                 {
159                         throw new NotImplementedException ();
160                 }
161
162                 public bool Remove (KeyValuePair<MessageFilter,TFilterData> item)
163                 {
164                         if (dict.ContainsKey (item.Key) && dict [item.Key].Equals (item.Value)) {
165                                 dict.Remove (item.Key);
166                                 return true;
167                         }
168                         return false;
169                 }
170
171                 public bool Remove (EndpointAddressMessageFilter filter)
172                 {
173                         throw new NotImplementedException ();
174                 }
175
176                 public bool Remove (MessageFilter filter)
177                 {
178                         return dict.Remove (filter);
179                 }
180
181                 public bool TryGetValue (MessageFilter filter, out TFilterData filterData)
182                 {
183                         if (dict.ContainsKey (filter)) {
184                                 filterData = dict [filter];
185                                 return true;
186                         } else {
187                                 filterData = default (TFilterData);
188                                 return false;
189                         }
190                 }
191         }
192 }