/// <summary> /// Gets an instance of the specified component type from the host. /// </summary> /// <param name="type">The component type to be retrieved</param> /// <returns>The component</returns> public IBuildComponent GetComponent(BuildComponentType type) { BuildComponentEntry componentEntry = null; if (!_componentEntriesByType.TryGetValue(type, out componentEntry)) { ErrorUtilities.ThrowInternalError("No factory registered for component type {0}", type); } return(componentEntry.GetInstance(_host)); }
/// <summary> /// Adds a factory. /// </summary> /// <param name="componentType">The type which is created by this factory.</param> /// <param name="factory">Delegate which is responsible for creating the Component.</param> /// <param name="creationPattern">Creation pattern.</param> public void AddFactory(BuildComponentType componentType, BuildComponentFactoryDelegate factory, CreationPattern creationPattern) { _componentEntriesByType[componentType] = new BuildComponentEntry(componentType, factory, creationPattern); }
/// <summary> /// Registers a factory to replace one of the defaults. Creation pattern is inherited from the original. /// </summary> /// <param name="componentType">The type which is created by this factory.</param> /// <param name="instance">The instance to be registered.</param> public void ReplaceFactory(BuildComponentType componentType, IBuildComponent instance) { ErrorUtilities.VerifyThrow(_componentEntriesByType[componentType].Pattern == CreationPattern.Singleton, "Previously existing factory for type {0} was not a singleton factory.", componentType); _componentEntriesByType[componentType] = new BuildComponentEntry(componentType, instance); }
/// <summary> /// Registers a factory to replace one of the defaults. Creation pattern is inherited from the original. /// </summary> /// <param name="componentType">The type which is created by this factory.</param> /// <param name="factory">The factory to be registered.</param> public void ReplaceFactory(BuildComponentType componentType, BuildComponentFactoryDelegate factory) { BuildComponentEntry existingEntry = _componentEntriesByType[componentType]; _componentEntriesByType[componentType] = new BuildComponentEntry(componentType, factory, existingEntry.Pattern); }
/// <summary> /// Shuts down a specific singleton component. /// </summary> public void ShutdownComponent(BuildComponentType componentType) { BuildComponentEntry existingEntry = _componentEntriesByType[componentType]; existingEntry.ShutdownSingletonInstance(); }
/// <summary> /// Adds a factory. /// </summary> /// <param name="componentType">The type which is created by this factory.</param> /// <param name="factory">Delegate which is responsible for creating the Component.</param> /// <param name="creationPattern">Creation pattern.</param> public void AddFactory(BuildComponentType componentType, BuildComponentFactoryDelegate factory, CreationPattern creationPattern) { _componentEntriesByType[componentType] = new BuildComponentEntry(componentType, factory, creationPattern); }
/// <summary> /// Registers a factory to replace one of the defaults. Creation pattern is inherited from the original. /// </summary> /// <param name="componentType">The type which is created by this factory.</param> /// <param name="instance">The instance to be registered.</param> public void ReplaceFactory(BuildComponentType componentType, IBuildComponent instance) { ErrorUtilities.VerifyThrow(_componentEntriesByType[componentType].Pattern == CreationPattern.Singleton, "Previously existing factory for type {0} was not a singleton factory.", componentType); _componentEntriesByType[componentType] = new BuildComponentEntry(componentType, instance); }
/// <summary> /// Registers a factory to replace one of the defaults. Creation pattern is inherited from the original. /// </summary> /// <param name="componentType">The type which is created by this factory.</param> /// <param name="factory">The factory to be registered.</param> public void ReplaceFactory(BuildComponentType componentType, BuildComponentFactoryDelegate factory) { BuildComponentEntry existingEntry = _componentEntriesByType[componentType]; _componentEntriesByType[componentType] = new BuildComponentEntry(componentType, factory, existingEntry.Pattern); }