Пример #1
0
        /// <summary>
        /// Cleans up the current <see cref="IServiceLocator"/> associated with the context.
        /// </summary>
        public virtual void Dispose()
        {
            BladeList components = GetAllBlades();

            if (components != null)
            {
                foreach (IBlade component in components)
                {
                    try {
                        //HACK: Yes, I know this is ugly but need to figure out how to best handle this
                        component.Dispose();
                    }
                    catch {
                        //TODO: Add better handling for this exception
                    }
                }
            }

            if (ServiceLocator == null)
            {
                return;
            }

            try {
                //TODO: Remove this piece since you'll be using the Factory method for injection.
                //HACK: Yes, I know this is ugly but need to figure out how to best handle this
                ServiceLocator.Dispose();
            }
            catch {
                //TODO: Add better handling for this exception
            }
        }
Пример #2
0
        public void Can_Add_Null_Blade_To_List()
        {
            var list = new BladeList {
                null
            };

            Assert.IsNotEmpty(list);
        }
Пример #3
0
        public void List_Initialized_With_Valid_List_Has_Items()
        {
            var list = new BladeList(new List <IBlade> {
                new MockBlade()
            });

            Assert.IsNotEmpty(list);
        }
Пример #4
0
        public void Can_Add_And_Remove_Null_Blade_To_List()
        {
            var list = new BladeList {null};
            Assert.IsNotEmpty(list);

            list.Remove(null);
            Assert.IsEmpty(list);
        }
Пример #5
0
        public void Can_Add_Valid_Blade_To_List()
        {
            var list = new BladeList {
                new MockBlade()
            };

            Assert.IsNotEmpty(list);
        }
Пример #6
0
        public void Can_Add_And_Remove_Valid_Blade_To_List() {
            Blade blade = new MockBlade();

            var list = new BladeList {blade};
            Assert.IsNotEmpty(list);

            list.Remove(blade);
            Assert.IsEmpty(list);
        }
Пример #7
0
        public void Can_Add_And_Remove_Null_Blade_To_List()
        {
            var list = new BladeList {
                null
            };

            Assert.IsNotEmpty(list);

            list.Remove(null);
            Assert.IsEmpty(list);
        }
Пример #8
0
        public void Can_Add_And_Remove_Valid_Blade_To_List()
        {
            Blade blade = new MockBlade();

            var list = new BladeList {
                blade
            };

            Assert.IsNotEmpty(list);

            list.Remove(blade);
            Assert.IsEmpty(list);
        }
Пример #9
0
        /// <summary>
        /// Performs the given <see cref="Action{T}"/> for all registered
        /// <see cref="IBlade"/> in the system.
        /// </summary>
        /// <param name="bladeAction">Action to perform for each <see cref="IBlade"/>.</param>
        private void PerformBladeAction(Action <IBlade> bladeAction)
        {
            if (bladeAction == null)
            {
                return;
            }

            BladeList components = GetAllBlades();

            if (components == null || components.Count == 0)
            {
                return;
            }

            foreach (IBlade component in components)
            {
                bladeAction(component);
            }
        }
Пример #10
0
        /// <summary>
        /// Gets the list of components that are to be used for the application.
        /// </summary>
        /// <returns>A list of the components registered with the application.</returns>
        public virtual BladeList GetAllBlades()
        {
            if (bladeList == null)
            {
                lock (_lock) {
                    if (bladeList == null)
                    {
                        bladeList = new BladeList(CoreBlades.GetBlades());

                        var commonBlades = GetCommonBlades();

                        if (commonBlades != null)
                        {
                            bladeList.AddRange(commonBlades);
                        }
                    }
                }
            }

            return(bladeList);
        }
Пример #11
0
        /// <summary>
        /// Gets the list of components that are to be used for the application.
        /// </summary>
        /// <returns>A list of the components registered with the application.</returns>
        public virtual BladeList GetAllBlades()
        {
            var list = new BladeList(CoreBlades.GetBlades());

            BladeList commonBlades = GetCommonBlades();
            if (commonBlades != null) {
                list.AddRange(commonBlades);
            }

            return list;
        }
Пример #12
0
 public void List_Initialized_With_Valid_List_Has_Items()
 {
     var list = new BladeList(new List<IBlade> {new MockBlade()});
     Assert.IsNotEmpty(list);
 }
Пример #13
0
 public void Can_Create_Valid_Instance()
 {
     var list = new BladeList();
     Assert.IsNotNull(list);
 }
Пример #14
0
        public void Can_Add_Valid_Blade_To_List()
        {
            var list = new BladeList {new MockBlade()};

            Assert.IsNotEmpty(list);
        }
Пример #15
0
        public void Can_Add_Null_Blade_To_List()
        {
            var list = new BladeList {null};

            Assert.IsNotEmpty(list);
        }
Пример #16
0
        public void Can_Create_Valid_Instance()
        {
            var list = new BladeList();

            Assert.IsNotNull(list);
        }
Пример #17
0
        /// <summary>
        /// Gets the list of components that are to be used for the application.
        /// </summary>
        /// <returns>A list of the components registered with the application.</returns>
        public virtual BladeList GetAllBlades()
        {
            if (bladeList == null)
                lock (_lock) {
                    if (bladeList == null) {
                        // Get the CoreBlade from the container
                        var coreBlades = ServiceLocator.ResolveServices<CoreBlade>();
                        bladeList = new BladeList(coreBlades);

                        var commonBlades = GetCommonBlades();

                        if (commonBlades != null) {
                            bladeList.AddRange(commonBlades);
                        }
                    }
                }

            return bladeList;
        }
Пример #18
0
        /// <summary>
        /// Gets the list of components that are to be used for the application.
        /// </summary>
        /// <returns>A list of the components registered with the application.</returns>
        public virtual BladeList GetAllBlades()
        {
            if (bladeList == null)
                lock (_lock) {
                    if (bladeList == null) {
                        bladeList = new BladeList(CoreBlades.GetBlades());

                        var commonBlades = GetCommonBlades();

                        if (commonBlades != null) {
                            bladeList.AddRange(commonBlades);
                        }
                    }
                }

            return bladeList;
        }