Merge pull request #1505 from esdrubal/tzifloatingrule
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / ProfileParameter.cs
1 //
2 // (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
3 //
4 // Authors:
5 //      Vladimir Krasnov <vladimirk@mainsoft.com>
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26
27
28 using System;
29 using System.Collections.Generic;
30 using System.ComponentModel;
31 using System.Data;
32 using System.Text;
33
34 namespace System.Web.UI.WebControls
35 {
36         [DefaultProperty ("PropertyName")]
37         public class ProfileParameter : Parameter
38         {
39                 public ProfileParameter ()
40                         : base ()
41                 {
42                 }
43
44                 protected ProfileParameter (ProfileParameter original)
45                         : base (original)
46                 {
47                         this.PropertyName = original.PropertyName;
48                 }
49
50                 public ProfileParameter (string name, string propertyName)
51                         : base (name)
52                 {
53                         this.PropertyName = propertyName;
54                 }
55
56                 public ProfileParameter (string name, TypeCode type, string propertyName)
57                         : base (name, type)
58                 {
59                         this.PropertyName = propertyName;
60                 }
61
62                 public ProfileParameter (string name, DbType dbType, string propertyName)
63                         : base (name, dbType)
64                 {
65                         this.PropertyName = propertyName;
66                 }
67                 
68                 protected override Parameter Clone ()
69                 {
70                         return new ProfileParameter (this);
71                 }
72                 protected internal
73                 override object Evaluate (HttpContext context, Control control)
74                 {
75                         if (context == null || context.Profile == null)
76                                 return null;
77
78                         if (string.IsNullOrEmpty (PropertyName))
79                                 return null;
80
81                         return context.Profile [PropertyName];
82                 }
83
84                 [DefaultValue ("")]
85                 public string PropertyName {
86                         get {
87                                 object o = ViewState ["PropertyName"];
88                                 return (o != null) ? (string) o : string.Empty;
89                         }
90                         set { ViewState ["PropertyName"] = value; }
91                 }
92
93         }
94 }
95