/// <summary> /// Liste des stratégies concernant ce modèle /// </summary> /// <param name="specific"></param> /// <returns></returns> public List <StrategyBase> GetStrategies(bool specific) { return(StrategyManager.GetStrategies(StrategiesOwner, specific ? this : null)); }
public IList <IStrategy> GetStrategies() { return(_strategyManager.GetStrategies()); }
/// <summary> /// Notifies the publish events. /// </summary> /// <param name="model">The model.</param> /// <param name="fileName">Name of the file.</param> /// <param name="eventType">Type of the event.</param> internal static void NotifyPublishEvents(CandleModel model, string fileName, PublishEventType eventType) { ILogger logger = ServiceLocator.Instance.GetService <ILogger>(); if (logger != null) { logger.BeginStep("Custom strategy publishing actions", LogType.Info); } try { foreach (StrategyBase strategy in StrategyManager.GetStrategies(model.Component, null)) { if (!strategy.IsEnabled) { continue; } try { s_context = new GenerationContext(model, fileName, Guid.Empty); s_context.GenerationPass = GenerationPass.Publishing; strategy.InitializeContext(s_context, model.Component); switch (eventType) { case PublishEventType.EndPublish: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnPublicationEnded(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.PublishFailed: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnPublicationError(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.BeforeLocal: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnBeforeLocalPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.AfterLocal: if (strategy is IStrategyPublisher) { string folder = Path.GetDirectoryName(model.MetaData.GetFileName(PathKind.Absolute)); ((IStrategyPublisher)strategy).Publish(model, folder); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy custom publishing action for " + strategy.DisplayName, LogType.Info); } } if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnAfterLocalPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy after local custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.BeforeServer: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnBeforeServerPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy before server custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; case PublishEventType.AfterServer: if (strategy is IStrategyPublishEvents) { ((IStrategyPublishEvents)strategy).OnAfterServerPublication(model, fileName); if (logger != null) { logger.Write("Custom strategy publishing actions", "Executing strategy after server custom publishing action for " + strategy.DisplayName, LogType.Info); } } break; } } catch (PublishingException pe) { if (logger != null) { logger.WriteError("Custom strategy publishing actions", "Publishing stopped for strategy custom publishing action for " + strategy.DisplayName, pe); } throw; } catch (Exception ex) { if (logger != null) { logger.WriteError("Custom strategy publishing actions", "Error for strategy custom publishing action for " + strategy.DisplayName, ex); } } finally { strategy.InitializeContext(null, null); } } } finally { if (logger != null) { logger.EndStep(); } } }