/// <inheritdoc /> public ContentService(ILogger <ContentService> logger, IContentCommand contentCommand, ISystemClock systemClock, IGroupCommand groupCommand) { _systemClock = systemClock ?? throw new ArgumentNullException(nameof(systemClock)); _contentCommand = contentCommand ?? throw new ArgumentNullException(nameof(contentCommand)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _groupCommand = groupCommand; }
private void ProcessIncludedFiles(Command command) { if (command is IContainerCommand) { IContainerCommand iContainer = (IContainerCommand)command; if (iContainer.InnerCommands == null) { return; } foreach (Command cmd in iContainer.InnerCommands) { ProcessIncludedFiles(cmd); } } if (command is IContentCommand) { IContentCommand cntCommand = (IContentCommand)command; string sourceFilePath = cntCommand.ContentPath; if (sourceFilePath == null) { return; } if (sourceFilePath.Contains(ExecutionContext.PACKAGE_CONTENT_TAG) || sourceFilePath.Contains(ExecutionContext.GIN_EXE_TAG)) { return; } cntCommand.ContentPath = _content.AddContent(sourceFilePath); } if (command is IMultipleContentCommand) { IMultipleContentCommand cntCommand = (IMultipleContentCommand)command; if (cntCommand.ContentPaths != null) { foreach (ContentPath p in cntCommand.ContentPaths) { string sourceFilePath = p.Value; if (sourceFilePath == null) { return; } if (sourceFilePath.Contains(ExecutionContext.PACKAGE_CONTENT_TAG) || sourceFilePath.Contains(ExecutionContext.GIN_EXE_TAG)) { return; } p.Value = _content.AddContent(sourceFilePath); } } } }
private void CheckPackageSourceNeeds(Command command) { if (command is IContentCommand) { IContentCommand iCont = (IContentCommand)command; if (iCont.ContentPath != null && iCont.ContentPath.StartsWith(ExecutionContext.PACKAGE_SOURCE_TAG)) { if (!_containsPackageSource && String.IsNullOrEmpty(_body.IncludedPath)) { _errors.Add(new PackageErrorInfo { Body = _body, Command = null, Description = "В пакете используется доступ по относительным путям %PACKAGE_SOURCE%. Необходимо указать для пакета путь к исходным файлам, включаемым в пакет." }); _containsPackageSource = true; } else { CheckFilePresent(command); } } } if (command is IMultipleContentCommand) { IMultipleContentCommand iCont = (IMultipleContentCommand)command; foreach (ContentPath p in iCont.ContentPaths) { if (p.Value != null && p.Value.StartsWith(ExecutionContext.PACKAGE_SOURCE_TAG)) { if (!_containsPackageSource && String.IsNullOrEmpty(_body.IncludedPath)) { _errors.Add(new PackageErrorInfo { Body = _body, Command = null, Description = "В пакете используется доступ по относительным путям %PACKAGE_SOURCE%. Необходимо указать для пакета путь к исходным файлам, включаемым в пакет." }); _containsPackageSource = true; } else { CheckFilePresent(command); } } } } }
private void CheckFilePresent(Command command) { //#warning нет проверки для IMultipleContentCommand if (!(command is IContentCommand)) { return; } IContentCommand iCont = (IContentCommand)command; string contentPath = iCont.ContentPath; if (contentPath.Contains(ExecutionContext.PACKAGE_CONTENT_TAG)) { return; } string currentPath = null; if (contentPath.Contains(ExecutionContext.PACKAGE_SOURCE_TAG)) { currentPath = contentPath.Replace(ExecutionContext.PACKAGE_SOURCE_TAG, _body.IncludedPath); } if (String.IsNullOrEmpty(currentPath)) { _errors.Add(new PackageErrorInfo { Body = _body, Command = command, Description = "У команды <" + command.GetHumanReadableName() + "> отсутствует указание на исходный файловый объект." }); return; } if (!File.Exists(currentPath) && !Directory.Exists(currentPath)) { _errors.Add(new PackageErrorInfo { Body = _body, Command = command, Description = "У команды <" + command.GetHumanReadableName() + "> указан исходный файловый объект '" + currentPath + "' отсутствующий физически в указанном расположении." }); } }
public void AddCommand(string name, IContentCommand command) { baseEngine.AddCommand(name, command); }
public void AddCommand(string name, IContentCommand command) => engine.AddCommand(name, command);