PageRenderTime 23ms CodeModel.GetById 16ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
C# | 63 lines | 43 code | 12 blank | 8 comment | 2 complexity | 0eeecaf9d7bf2caa32d684880f99ea4b 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;
11using System.Collections;
12using System.ComponentModel;
13using Microsoft.Web.Management.Client;
14using Microsoft.Web.Management.Client.Win32;
15
16namespace Web.Management.PHP.Settings
17{
18
19    internal class SettingPropertyGridObject : PropertyGridObject
20    {
21
22        public SettingPropertyGridObject(ModulePropertiesPage page)
23            : this(page, false)
24        {
25        }
26
27        public SettingPropertyGridObject(ModulePropertiesPage page, bool readOnly)
28            : base(page, readOnly)
29        {
30        }
31
32        protected override System.ComponentModel.PropertyDescriptorCollection GetProperties(Attribute[] attributes)
33        {
34            PropertyDescriptorCollection props = base.GetProperties(attributes);
35
36            Type thisType = GetType();
37            ArrayList properties = new ArrayList();
38            foreach (PropertyDescriptor prop in props)
39            {
40                AttributeCollection collection = prop.Attributes;
41
42                SettingDisplayNameAttribute displayNameAttribute =
43                    (SettingDisplayNameAttribute)(collection[typeof(SettingDisplayNameAttribute)]);
44
45                if (displayNameAttribute != null)
46                {
47                    DisplayNameAttribute newDisplayNameAttribute =
48                        GetDisplayNameAttribute(displayNameAttribute.FriendlyName, displayNameAttribute.ConfigPropertyName);
49
50                    properties.Add(TypeDescriptor.CreateProperty(thisType, prop, newDisplayNameAttribute));
51                }
52                else
53                {
54                    properties.Add(prop);
55                }
56            }
57
58            props = new PropertyDescriptorCollection((PropertyDescriptor[])properties.ToArray(typeof(PropertyDescriptor)));
59            return props;
60        }
61
62    }
63}