2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Web.Mobile / System.Web.Mobile / DeviceFilterDictionary.cs
1
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining
4 // a copy of this software and associated documentation files (the
5 // "Software"), to deal in the Software without restriction, including
6 // without limitation the rights to use, copy, modify, merge, publish,
7 // distribute, sublicense, and/or sell copies of the Software, and to
8 // permit persons to whom the Software is furnished to do so, subject to
9 // the following conditions:
10 // 
11 // The above copyright notice and this permission notice shall be
12 // included in all copies or substantial portions of the Software.
13 // 
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 //
22 /**
23  * Project   : Mono
24  * Namespace : System.Web.Mobile
25  * Class     : DeviceFilterDictionary
26  * Author    : Gaurav Vaish
27  *
28  * Copyright : 2003 with Gaurav Vaish, and with
29  *             Ximian Inc
30  */
31
32 using System;
33 using System.Collections;
34 using System.Web;
35 using System.Web.UI;
36
37 namespace System.Web.Mobile
38 {
39         class DeviceFilterDictionary
40         {
41                 internal class ComparisonEvaluator
42                 {
43                         public readonly string Name;
44                         public readonly string Argument;
45
46                         public ComparisonEvaluator(string name, string argument)
47                         {
48                                 this.Name = name;
49                                 this.Argument = argument;
50                         }
51                 }
52
53                 // for comparisons
54                 private Hashtable cmpEvaluators;
55
56                 // for delegates
57                 private Hashtable dlgEvaluators;
58
59                 internal DeviceFilterDictionary()
60                 {
61                         this.cmpEvaluators = new Hashtable();
62                         this.dlgEvaluators = new Hashtable();
63                 }
64
65                 internal DeviceFilterDictionary(DeviceFilterDictionary init)
66                 {
67                         this.cmpEvaluators = (Hashtable)init.cmpEvaluators.Clone();
68                         this.dlgEvaluators = (Hashtable)init.dlgEvaluators.Clone();
69                 }
70
71                 internal void AddCapabilityDelegate(string name,
72                                    MobileCapabilities.EvaluateCapabilitiesHandler handler)
73                 {
74                         dlgEvaluators[name] = handler;
75                 }
76
77                 internal void AddComparisonDelegate(string delegateName,
78                                   string comparisonName, string argument)
79                 {
80                         this.cmpEvaluators[delegateName] =
81                                 new ComparisonEvaluator(comparisonName, argument);
82                 }
83
84                 private void InvalidateComparisonDelegateLoops(string name)
85                 {
86                         // throws exception in case of a loop
87                         throw new NotImplementedException();
88                 }
89
90                 internal bool LocateComparisonEvaluator(string evaluatorName,
91                                out string capabilityName, out string capArgument)
92                 {
93                         throw new NotImplementedException();
94                 }
95
96                 internal bool LocateDelegateEvaluator(string name,
97                      out MobileCapabilities.EvaluateCapabilitiesHandler result)
98                 {
99                         throw new NotImplementedException();
100                 }
101
102                 internal bool IsComparisonEvaluator(string name)
103                 {
104                         return cmpEvaluators.Contains(name);
105                 }
106
107                 internal bool IsDelegateEvaluator(string name)
108                 {
109                         return dlgEvaluators.Contains(name);
110                 }
111         }
112 }