PageRenderTime 27ms CodeModel.GetById 21ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/stable-1.1.2/Client/Settings/SettingDisplayNameAttribute.cs

#
C# | 48 lines | 31 code | 9 blank | 8 comment | 1 complexity | 8effe7835fed1e4210a156301f24811c MD5 | raw file
 1//-----------------------------------------------------------------------
 2// <copyright>
 3// Copyright (C) Ruslan Yakushev for the PHP Manager for IIS project.
 4//
 5// This file is subject to the terms and conditions of the Microsoft Public License (MS-PL).
 6// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL for more details.
 7// </copyright>
 8//----------------------------------------------------------------------- 
 9
10using System;
11
12namespace Web.Management.PHP.Settings
13{
14
15    [AttributeUsage(AttributeTargets.Property|AttributeTargets.Event|AttributeTargets.Class)]
16    internal sealed class SettingDisplayNameAttribute : Attribute {
17
18        private bool _replaced;
19        private string _configPropertyName;
20        private string _friendlyName;
21
22        internal SettingDisplayNameAttribute(string friendlyName) {
23            _friendlyName = friendlyName;
24        }
25
26        internal SettingDisplayNameAttribute(string friendlyName, string configPropertyName) {
27            _friendlyName = friendlyName;
28            _configPropertyName = configPropertyName;
29        }
30
31        public string ConfigPropertyName {
32            get {
33                return _configPropertyName;
34            }
35        }
36
37        public string FriendlyName {
38            get {
39                if (!_replaced) {
40                    _replaced = true;
41                    _friendlyName = Resources.ResourceManager.GetString(_friendlyName);
42                }
43
44                return _friendlyName;
45            }
46        }
47    }
48}