/// <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 } }
public void Can_Add_Null_Blade_To_List() { var list = new BladeList { null }; Assert.IsNotEmpty(list); }
public void List_Initialized_With_Valid_List_Has_Items() { var list = new BladeList(new List <IBlade> { new MockBlade() }); Assert.IsNotEmpty(list); }
public void Can_Add_And_Remove_Null_Blade_To_List() { var list = new BladeList {null}; Assert.IsNotEmpty(list); list.Remove(null); Assert.IsEmpty(list); }
public void Can_Add_Valid_Blade_To_List() { var list = new BladeList { new MockBlade() }; Assert.IsNotEmpty(list); }
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); }
public void Can_Add_And_Remove_Null_Blade_To_List() { var list = new BladeList { null }; Assert.IsNotEmpty(list); list.Remove(null); Assert.IsEmpty(list); }
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); }
/// <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); } }
/// <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); }
/// <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; }
public void List_Initialized_With_Valid_List_Has_Items() { var list = new BladeList(new List<IBlade> {new MockBlade()}); Assert.IsNotEmpty(list); }
public void Can_Create_Valid_Instance() { var list = new BladeList(); Assert.IsNotNull(list); }
public void Can_Add_Valid_Blade_To_List() { var list = new BladeList {new MockBlade()}; Assert.IsNotEmpty(list); }
public void Can_Add_Null_Blade_To_List() { var list = new BladeList {null}; Assert.IsNotEmpty(list); }
/// <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; }
/// <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; }