Mercurial > altnet-hispano
comparison Agendas/trunk/src/Agendas.Web/PublicadoresConfig.cs @ 127:3700b77ed455
Configuracion de publicadores
author | jorge.rowies |
---|---|
date | Sat, 02 Jul 2011 21:50:05 -0300 |
parents | |
children | 1e47bf408073 |
comparison
equal
deleted
inserted
replaced
126:6012f2becf97 | 127:3700b77ed455 |
---|---|
1 using System; | |
2 using System.Collections.Generic; | |
3 using System.Configuration; | |
4 using System.Linq; | |
5 using System.Web; | |
6 using System.Reflection; | |
7 | |
8 namespace AltNetHispano.Agendas.Web | |
9 { | |
10 public class PublicadorConfigurationElement : ConfigurationElement | |
11 { | |
12 [ConfigurationProperty("name", IsRequired = true)] | |
13 public string Name | |
14 { | |
15 get { return (string)this["name"]; } | |
16 } | |
17 | |
18 [ConfigurationProperty("type", IsRequired = true)] | |
19 public string Type | |
20 { | |
21 get | |
22 { | |
23 return (string)this["type"]; | |
24 } | |
25 } | |
26 | |
27 public Type GetPublicadorType() | |
28 { | |
29 return System.Type.GetType((string) this["type"]); | |
30 } | |
31 | |
32 [ConfigurationProperty("enabled", IsRequired = true)] | |
33 public bool Enabled | |
34 { | |
35 get { return (bool)this["enabled"]; } | |
36 } | |
37 } | |
38 | |
39 [ConfigurationCollection(typeof(PublicadorConfigurationElement))] | |
40 public class PublicadorConfigurationCollection : ConfigurationElementCollection | |
41 { | |
42 protected override ConfigurationElement CreateNewElement() | |
43 { | |
44 return new PublicadorConfigurationElement(); | |
45 } | |
46 | |
47 protected override object GetElementKey(ConfigurationElement element) | |
48 { | |
49 var value = element as PublicadorConfigurationElement; | |
50 return value != null ? value.Name : null; | |
51 } | |
52 | |
53 public PublicadorConfigurationElement this[int index] | |
54 { | |
55 get | |
56 { | |
57 return BaseGet(index) as PublicadorConfigurationElement; | |
58 } | |
59 set | |
60 { | |
61 if (BaseGet(index) != null) | |
62 BaseRemoveAt(index); | |
63 BaseAdd(index, value); | |
64 } | |
65 } | |
66 | |
67 public new PublicadorConfigurationElement this[string name] | |
68 { | |
69 get | |
70 { | |
71 return BaseGet(name) as PublicadorConfigurationElement; | |
72 } | |
73 } | |
74 } | |
75 | |
76 public class PublicadorConfigurationSection : ConfigurationSection | |
77 { | |
78 [ConfigurationProperty("publicadores", IsRequired = true)] | |
79 public PublicadorConfigurationCollection Publicadores | |
80 { | |
81 get | |
82 { | |
83 return this["publicadores"] | |
84 as PublicadorConfigurationCollection; | |
85 } | |
86 } | |
87 } | |
88 } |