protected override void BaseAdd(ConfigurationElement element) { BrokerElement be = (BrokerElement)element; if (this.BaseGet((Object)be.Key) != null) { throw new ConfigurationErrorsException("duplicate broker definition at line " + element.ElementInformation.LineNumber); } base.BaseAdd(element); }
protected override void PostDeserialize() { base.PostDeserialize(); if (this.Count == 0) { throw new ArgumentException("Brokers collection requires at least one broker"); } if (this.Count > 1) { Console.WriteLine("Warning: multiple brokers not supported, selecting first instance"); } BrokerElement be = (BrokerElement)this.BaseGet(0); }
protected override void PostDeserialize() { base.PostDeserialize(); BrokerCollection brokers = Brokers; if (brokers != null) { if (brokers.Count > 0) { // just grab the first element until failover is supported System.Collections.IEnumerator brokersEnum = brokers.GetEnumerator(); // move to first element brokersEnum.MoveNext(); BrokerElement be = (BrokerElement)brokersEnum.Current; this.BrokerHost = be.Host; this.BrokerPort = be.Port; } } }
protected override Object GetElementKey(ConfigurationElement element) { BrokerElement be = (BrokerElement)element; return(be.Key); }