예제 #1
0
 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);
     }
 }
 public void Add(ComponentElement element)
 {
     if (null != element)
     {
         base.BaseAdd(element, false);
     }
 }
예제 #4
0
파일: Initializer.cs 프로젝트: t1b1c/lwas
        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);
        }
예제 #5
0
파일: Initializer.cs 프로젝트: t1b1c/lwas
        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();
            }
        }
예제 #6
0
 public void Remove(ComponentElement element)
 {
     if (base.BaseIndexOf(element) >= 0)
     {
         base.BaseRemove(element.Name);
     }
 }
예제 #7
0
 public int IndexOf(ComponentElement element)
 {
     return base.BaseIndexOf(element);
 }
예제 #8
0
 public void Add(ComponentElement element)
 {
     this.BaseAdd(element);
 }
예제 #9
0
 public void Add(ComponentElement element)
 {
     this.BaseAdd(element);
 }
예제 #10
0
 public int IndexOf(ComponentElement element)
 {
     return(base.BaseIndexOf(element));
 }
예제 #11
0
파일: Initializer.cs 프로젝트: t1b1c/lwas
        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);
            }
        }
예제 #12
0
파일: Initializer.cs 프로젝트: t1b1c/lwas
 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);
     }
 }
예제 #13
0
파일: Initializer.cs 프로젝트: t1b1c/lwas
 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;
 }