Mercurial > altnet-hispano
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Agendas/trunk/src/Agendas.Web/PublicadoresConfig.cs Sat Jul 02 21:50:05 2011 -0300 @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Linq; +using System.Web; +using System.Reflection; + +namespace AltNetHispano.Agendas.Web +{ + public class PublicadorConfigurationElement : ConfigurationElement + { + [ConfigurationProperty("name", IsRequired = true)] + public string Name + { + get { return (string)this["name"]; } + } + + [ConfigurationProperty("type", IsRequired = true)] + public string Type + { + get + { + return (string)this["type"]; + } + } + + public Type GetPublicadorType() + { + return System.Type.GetType((string) this["type"]); + } + + [ConfigurationProperty("enabled", IsRequired = true)] + public bool Enabled + { + get { return (bool)this["enabled"]; } + } + } + + [ConfigurationCollection(typeof(PublicadorConfigurationElement))] + public class PublicadorConfigurationCollection : ConfigurationElementCollection + { + protected override ConfigurationElement CreateNewElement() + { + return new PublicadorConfigurationElement(); + } + + protected override object GetElementKey(ConfigurationElement element) + { + var value = element as PublicadorConfigurationElement; + return value != null ? value.Name : null; + } + + public PublicadorConfigurationElement this[int index] + { + get + { + return BaseGet(index) as PublicadorConfigurationElement; + } + set + { + if (BaseGet(index) != null) + BaseRemoveAt(index); + BaseAdd(index, value); + } + } + + public new PublicadorConfigurationElement this[string name] + { + get + { + return BaseGet(name) as PublicadorConfigurationElement; + } + } + } + + public class PublicadorConfigurationSection : ConfigurationSection + { + [ConfigurationProperty("publicadores", IsRequired = true)] + public PublicadorConfigurationCollection Publicadores + { + get + { + return this["publicadores"] + as PublicadorConfigurationCollection; + } + } + } +} \ No newline at end of file