annotate Agendas/trunk/src/Agendas.Web/PublicadoresConfig.cs @ 128:1e47bf408073

Asignacion de los publicadores configurados en web.config al factory de agenda (mediante CompositePublicador)
author jorge.rowies
date Mon, 04 Jul 2011 20:00:51 -0300
parents 3700b77ed455
children
rev   line source
127
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
1 using System;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
2 using System.Collections.Generic;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
3 using System.Configuration;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
4 using System.Linq;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
5 using System.Web;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
6 using System.Reflection;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
7
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
8 namespace AltNetHispano.Agendas.Web
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
9 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
10 public class PublicadorConfigurationElement : ConfigurationElement
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
11 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
12 [ConfigurationProperty("name", IsRequired = true)]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
13 public string Name
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
14 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
15 get { return (string)this["name"]; }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
16 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
17
128
1e47bf408073 Asignacion de los publicadores configurados en web.config al factory de agenda
jorge.rowies
parents: 127
diff changeset
18 [ConfigurationProperty("componentKey", IsRequired = true)]
1e47bf408073 Asignacion de los publicadores configurados en web.config al factory de agenda
jorge.rowies
parents: 127
diff changeset
19 public string ComponentKey
127
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
20 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
21 get
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
22 {
128
1e47bf408073 Asignacion de los publicadores configurados en web.config al factory de agenda
jorge.rowies
parents: 127
diff changeset
23 return (string)this["componentKey"];
127
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
24 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
25 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
26
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
27 [ConfigurationProperty("enabled", IsRequired = true)]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
28 public bool Enabled
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
29 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
30 get { return (bool)this["enabled"]; }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
31 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
32 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
33
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
34 [ConfigurationCollection(typeof(PublicadorConfigurationElement))]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
35 public class PublicadorConfigurationCollection : ConfigurationElementCollection
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
36 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
37 protected override ConfigurationElement CreateNewElement()
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
38 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
39 return new PublicadorConfigurationElement();
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
40 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
41
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
42 protected override object GetElementKey(ConfigurationElement element)
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
43 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
44 var value = element as PublicadorConfigurationElement;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
45 return value != null ? value.Name : null;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
46 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
47
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
48 public PublicadorConfigurationElement this[int index]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
49 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
50 get
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
51 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
52 return BaseGet(index) as PublicadorConfigurationElement;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
53 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
54 set
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
55 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
56 if (BaseGet(index) != null)
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
57 BaseRemoveAt(index);
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
58 BaseAdd(index, value);
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
59 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
60 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
61
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
62 public new PublicadorConfigurationElement this[string name]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
63 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
64 get
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
65 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
66 return BaseGet(name) as PublicadorConfigurationElement;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
67 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
68 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
69 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
70
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
71 public class PublicadorConfigurationSection : ConfigurationSection
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
72 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
73 [ConfigurationProperty("publicadores", IsRequired = true)]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
74 public PublicadorConfigurationCollection Publicadores
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
75 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
76 get
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
77 {
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
78 return this["publicadores"]
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
79 as PublicadorConfigurationCollection;
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
80 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
81 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
82 }
3700b77ed455 Configuracion de publicadores
jorge.rowies
parents:
diff changeset
83 }