public void Remove(ComponentElement element) { if (base.BaseIndexOf(element) >= 0) { base.BaseRemove(element.Name); } }
public void Add(ComponentElement element) { if (null != element) { base.BaseAdd(element, false); } }
protected virtual object GetProvider(ComponentElement providerElement) { object provider = null; if (this.singletons.ContainsKey(providerElement.Type)) { provider = this.singletons[providerElement.Type]; } else { provider = ReflectionServices.CreateInstance(providerElement.Type); this.Initialize(provider); } return(provider); }
public virtual void Initialize(object target) { if (null == target) { throw new ArgumentNullException("target"); } string key = target.GetType().FullName; if (target is IPageComponent) { ((IPageComponent)target).Page = this.Page; } if (target is IWatchdogSubscriber) { ((IWatchdogSubscriber)target).Watchdog = this._watchdog; } if (this.initializerSection.Components.Contains(key)) { ComponentElement componentElement = this.initializerSection.Components[key]; foreach (PropertyElement propertyElement in componentElement.PropertiesCollection) { if (string.IsNullOrEmpty(propertyElement.Value)) { foreach (ComponentElement item in propertyElement.ItemsCollection) { ReflectionServices.SetValue(target, propertyElement.Name, this.GetProvider(item)); } } else { ReflectionServices.SetValue(target, propertyElement.Name, propertyElement.Value); } } foreach (ComponentElement providerElement in componentElement.ProvidersCollection) { this.SetProviderToComponent(target, this.GetProvider(providerElement), providerElement); } if (componentElement.IsSingleton) { this.singletons.Add(componentElement.Type, target); } } if (target is IInitializable) { ((IInitializable)target).Initialize(); } }
public int IndexOf(ComponentElement element) { return base.BaseIndexOf(element); }
public void Add(ComponentElement element) { this.BaseAdd(element); }
public int IndexOf(ComponentElement element) { return(base.BaseIndexOf(element)); }
protected virtual void SetProviderToComponent(object target, object provider, ComponentElement componentElement) { if (null == target) { throw new ArgumentNullException("target"); } if (null == componentElement) { throw new ArgumentNullException("componentElement"); } object value = null; if (componentElement.SetOnlyWhenNull) { value = ReflectionServices.ExtractValue(target, componentElement.Name); } if (!componentElement.SetOnlyWhenNull || (componentElement.SetOnlyWhenNull && null == value)) { object setObject = provider; if (!string.IsNullOrEmpty(componentElement.Member)) { setObject = ReflectionServices.ExtractValue(provider, componentElement.Member); } ReflectionServices.SetValue(target, componentElement.Name, setObject); } }
protected virtual object GetProvider(ComponentElement providerElement) { object provider = null; if (this.singletons.ContainsKey(providerElement.Type)) { provider = this.singletons[providerElement.Type]; } else { provider = ReflectionServices.CreateInstance(providerElement.Type); this.Initialize(provider); } return provider; }