Home
Manage Your Code
Snippet: criar class para web config (C#)
Title: criar class para web config Language: C#
Description: criar class para web config Views: 110
Author: Rui Santos Date Added: 8/29/2008
Copy Code  
1using System;
2using System.Data;
3using System.Configuration;
4using System.Linq;
5using System.Web;
6using System.Web.Security;
7using System.Web.UI;
8
9/// <summary>
10/// Summary description for MenuConfigurationSection
11/// </summary>
12public class MenuSettings : ConfigurationSection
13{
14    private static MenuSettings settings = ConfigurationManager.GetSection("MenuSettings") as MenuSettings;
15
16    public static MenuSettings Settings
17    {
18        get{ return settings; }
19    }
20
21    [ConfigurationProperty("key", DefaultValue = "", IsRequired = true)]
22    [StringValidator(InvalidCharacters = "  ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 50)]
23    public string Key
24    {
25        get{ return this["key"] as string; }
26    }
27    
28    [ConfigurationProperty("title", DefaultValue = "", IsRequired = true)]
29    [StringValidator(InvalidCharacters = "  ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 50)]
30    public string Title
31    {
32        get{ return this["title"] as string;}
33    }
34
35    [ConfigurationProperty("description", DefaultValue = "", IsRequired = true)]
36    [StringValidator(InvalidCharacters = "  ~!@#$%^&*()[]{}/;’\"|\\", MinLength = 1, MaxLength = 256)]
37    public string Description
38    {
39        get{ return this["description"] as string; }
40    }
41
42    [ConfigurationProperty("order", DefaultValue = 1, IsRequired = true)]
43    [IntegerValidator( MinValue = 1, MaxValue = 20)]
44    public int Order 
45    {
46        get{ return (int)this["order"]; }
47    }
48
49}
50