public ChildrenOfPathBasedPresetTreeExclusion(string excludeChildrenOfPath, string[] exceptions, PresetTreeRoot root) { _excludeChildrenOfPath = excludeChildrenOfPath; // path that does not start with / is relative to the parent include root path // eg include /foo, path 'bar' => /foo/bar if (!_excludeChildrenOfPath.StartsWith("/")) _excludeChildrenOfPath = $"{root.Path.TrimEnd('/')}/{_excludeChildrenOfPath}"; // normalize the root path to have a trailing slash which will make the path match only children // (like implicit matching) _excludeChildrenOfPath = PathTool.EnsureTrailingSlash(_excludeChildrenOfPath); // convert all exceptions to full paths with a trailing slash (so we can match on path segments) _exceptions = exceptions.Select(exception => $"{PathTool.EnsureTrailingSlash(_excludeChildrenOfPath)}{exception}/").ToArray(); }
public PathBasedPresetTreeExclusion(string excludedPath, PresetTreeRoot root) { _excludedPath = excludedPath; // path that does not start with / is relative to the parent include root path if (!_excludedPath.StartsWith("/")) _excludedPath = $"{root.Path.TrimEnd('/')}/{_excludedPath}"; // for legacy compatibility you can exclude children by having a path exclusion end with a trailing slash // but since we add a trailing slash internally to all paths (so that we match by path e.g. /foo != /foot) // we need to know if the original string had a trailing slash and handle it as a child exclusion _implicitChildrenExclusion = _excludedPath.EndsWith("/"); // we internally add a trailing slash to the excluded path, and add a trailing slash to the incoming evaluate path // why? because otherwise using StartsWith would mean that /foo would also exclude /foot. But /foo/ and /foot/ do not match like that. _excludedPath = PathTool.EnsureTrailingSlash(_excludedPath); }
public PathBasedPresetTreeExclusion(string excludedPath, PresetTreeRoot root) { _excludedPath = excludedPath; // path that does not start with / is relative to the parent include root path if (!_excludedPath.StartsWith("/")) { _excludedPath = $"{root.Path.TrimEnd('/')}/{_excludedPath}"; } // for legacy compatibility you can exclude children by having a path exclusion end with a trailing slash // but since we add a trailing slash internally to all paths (so that we match by path e.g. /foo != /foot) // we need to know if the original string had a trailing slash and handle it as a child exclusion _implicitChildrenExclusion = _excludedPath.EndsWith("/"); // we internally add a trailing slash to the excluded path, and add a trailing slash to the incoming evaluate path // why? because otherwise using StartsWith would mean that /foo would also exclude /foot. But /foo/ and /foot/ do not match like that. _excludedPath = PathTool.EnsureTrailingSlash(_excludedPath); }
public ChildrenOfPathBasedPresetTreeExclusion(string excludeChildrenOfPath, string[] exceptions, PresetTreeRoot root) { _excludeChildrenOfPath = excludeChildrenOfPath; // path that does not start with / is relative to the parent include root path // eg include /foo, path 'bar' => /foo/bar if (!_excludeChildrenOfPath.StartsWith("/")) { _excludeChildrenOfPath = $"{root.Path.TrimEnd('/')}/{_excludeChildrenOfPath}"; } // normalize the root path to have a trailing slash which will make the path match only children // (like implicit matching) _excludeChildrenOfPath = PathTool.EnsureTrailingSlash(_excludeChildrenOfPath); // convert all exceptions to full paths with a trailing slash (so we can match on path segments) _exceptions = exceptions.Select(exception => $"{PathTool.EnsureTrailingSlash(_excludeChildrenOfPath)}{exception}/").ToArray(); }
public TemplateBasedPresetExclusion(string templateId, PresetTreeRoot root) { _excludedTemplate = templateId; }
protected virtual BulkLoadAction GetBulkLoadAction(DataBlasterParameters parameters, IConfiguration configuration, PresetTreeRoot treeRoot) { if (parameters.ForceBulkLoadAction.HasValue) { return(parameters.ForceBulkLoadAction.Value); } var evaluator = configuration.Resolve <IEvaluator>(); if (evaluator is SerializedAsMasterEvaluator) { // Only revert the tree when there are no exclusions for this tree root. return(treeRoot.Exclusions == null || treeRoot.Exclusions.Count == 0 ? BulkLoadAction.RevertTree : BulkLoadAction.Revert); } if (evaluator is NewItemOnlyEvaluator) { return(BulkLoadAction.AddItemOnly); } //if (evaluator is AddOnlyEvaluator) //{ // return BulkLoadAction.AddOnly; //} throw new ArgumentException($"Unknown evaluator type: '{evaluator.GetType().Name}'"); }