コード例 #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
ファイル: RotorContext.cs プロジェクト: jsmale/mvcturbine
        /// <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
ファイル: RotorContext.cs プロジェクト: Ang3lFir3/mvcturbine
        /// <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;
        }