1 /* AspNetPager version 7.3.2
2 Copyright (C) 2003-2010 Webdiyer(http://en.webdiyer.com)
3
4 This file is part of AspNetPager.
5
6 AspNetPager is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 AspNetPager is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with AspNetPager. If not, see <http://www.gnu.org/licenses/>.
18 */
1 using System;
2 using System.Resources;
3 using System.ComponentModel;
4 using System.Web.UI;
5 using System.Web.UI.WebControls;
6
7 namespace Wuqi.Webdiyer
8 {
9 #region Custom Attributes
10
11 [AttributeUsage(AttributeTargets.All)]
12 internal sealed class ANPDescriptionAttribute : DescriptionAttribute
13 {
14 public ANPDescriptionAttribute(string text) : base(text)
15 {
16 replaced = false;
17 }
18
19 public override string Description
20 {
21 get
22 {
23 if (!replaced)
24 {
25 replaced = true;
26 DescriptionValue = SR.GetString(DescriptionValue);
27 }
28 return base.Description;
29 }
30 }
31 private bool replaced;
32 }
33
34 [AttributeUsage(AttributeTargets.All)]
35 internal class ANPCategoryAttribute : CategoryAttribute
36 {
37 internal ANPCategoryAttribute(string name) : base(name) { }
38
39 protected override string GetLocalizedString(string value)
40 {
41 string cat = base.GetLocalizedString(value);
42 if (null == cat)
43 cat = SR.GetString(value);
44 return cat;
45 }
46 }
47
48
49 [AttributeUsage(AttributeTargets.All)]
50 internal class ANPDefaultValueAttribute : DefaultValueAttribute
51 {
52 public ANPDefaultValueAttribute(string name)
53 : base(name)
54 {
55 localized = false;
56 }
57
58 public override object Value
59 {
60 get
61 {
62 if (!localized)
63 {
64 localized = true;
65 string defValue = (string)base.Value;
66 if (!string.IsNullOrEmpty(defValue))
67 {
68 return SR.GetString(defValue);
69 }
70 }
71 return base.Value;
72 }
73 }
74 private bool localized;
75 }
76
77 internal sealed class SR
78 {
79 private SR()
80 {
81 _rm = new ResourceManager("Wuqi.Webdiyer.AspNetPager", GetType().Assembly);
82 }
83
84 private ResourceManager Resources
85 {
86 get { return _rm; }
87 }
88
89 private ResourceManager _rm;
90
91
92 private static SR GetLoader()
93 {
94 if (null == _loader)
95 {
96 lock (_lock)
97 {
98 if (null == _loader)
99 _loader = new SR();
100 }
101 }
102 return _loader;
103 }
104
105 public static string GetString(string name)
106 {
107 SR loader = GetLoader();
108 string localized = null;
109 if (null != loader)
110 localized = loader.Resources.GetString(name, null);
111 return localized;
112 }
113
114 private static SR _loader = null;
115
116 private static object _lock = new object();
117 }
118
119 /// <summary>
120 /// AspNetPager type converter used for the design time support
121 /// </summary>
122 internal class AspNetPagerIDConverter : ControlIDConverter
123 {
124 protected override bool FilterControl(Control control)
125 {
126 if (control is AspNetPager)
127 return true;
128 return false;
129 }
130 }
131 #endregion
132 }