/// <summary> /// Sets the metadata key <c>WriteFileName</c> to an optimized version of the return value of the delegate. /// Also sets the metadata key <c>WritePath</c> to <c>Path.Combine(RelativeFileDir, WriteFileName)</c>. /// </summary> /// <param name="fileName">A delegate that should return a <c>string</c> with the filename to optimize.</param> public FileName(DocumentConfig fileName) { if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } _fileName = fileName; }
/// <summary> /// Defines the delegate that will be invoked against each input document to get the case comparison value. /// </summary> /// <param name="value">A delegate that returns an object to compare cases against.</param> public Switch(DocumentConfig value) { if (value == null) { throw new ArgumentNullException(nameof(value)); } _value = value; }
/// <summary> /// Limits the documents passed to the child modules to those that satisfy the /// supplied predicate. All original input documents are output without /// modification regardless of whether they satisfy the predicate. /// </summary> /// <param name="predicate">A delegate that should return a <c>bool</c>.</param> public ConcatBranch Where(DocumentConfig predicate) { Func<IDocument, IExecutionContext, bool> currentPredicate = _predicate; _predicate = currentPredicate == null ? (Func<IDocument, IExecutionContext, bool>)(predicate.Invoke<bool>) : ((x, c) => currentPredicate(x, c) && predicate.Invoke<bool>(x, c)); return this; }
public OrderBy(DocumentConfig key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } _key = key; }
protected ReadWorkspace(DocumentConfig path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } _path = new ConfigHelper<string>(path); }
/// <summary> /// Uses a function to determine a text template which is processed and added as metadata for each document. /// This allows you to specify different metadata for each document depending on the input. /// </summary> /// <param name="key">The metadata key for the generated text.</param> /// <param name="template">A delegate that returns the template to use.</param> public GenerateMeta(string key, DocumentConfig template) : base(template) { if (key == null) { throw new ArgumentNullException(nameof(key)); } _key = key; }
protected ReadWorkspace(DocumentConfig path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } _pathDelegate = path; }
// This will get documents based on each input document - the result will be the aggregate of all returned documents for each input document // The delegate should return a IEnumerable<IDocument> public Documents(DocumentConfig documents) { if (documents == null) { throw new ArgumentNullException(nameof(documents)); } _documentDocuments = documents; }
/// <summary> /// Specifies a delegate that should be invoked once for each input document. /// This will return the input documents. /// </summary> /// <param name="execute">A delegate to invoke that should return a <see cref="IEnumerable{IDocument}"/>.</param> public Execute(Action<IDocument, IExecutionContext> execute) { _executeDocument = (doc, ctx) => { execute(doc, ctx); return null; }; }
/// <summary> /// Uses a function to determine an object to be added as metadata for each document. /// This allows you to specify different metadata for each document depending on the input. /// </summary> /// <param name="key">The metadata key to set.</param> /// <param name="metadata">A delegate that returns the object to add as metadata.</param> public Meta(string key, DocumentConfig metadata) { if (key == null) { throw new ArgumentNullException(nameof(key)); } _key = key; _metadata = new ConfigHelper<object>(metadata); }
/// <summary> /// Creates a sitemap using the specified delegate which should return either a <c>string</c> that /// contains the location for each input document or a <c>SitemapItem</c> instance with the location /// and other information. /// </summary> /// <param name="sitemapItemOrLocation">A delegate that either returns a <c>SitemapItem</c> instance or a <c>string</c> /// with the desired item location. If the delegate returns <c>null</c>, the input document is not added to the sitemap.</param> /// <param name="locationFormatter">A location formatter that will be applied to the location of each input after /// getting the value of the specified metadata key.</param> public Sitemap(DocumentConfig sitemapItemOrLocation, Func<string, string> locationFormatter = null) { if (sitemapItemOrLocation == null) { throw new ArgumentNullException(nameof(sitemapItemOrLocation)); } _sitemapItemOrLocation = sitemapItemOrLocation; _locationFormatter = locationFormatter; }
public OrderBy ThenBy(DocumentConfig key) { if (key == null) { throw new ArgumentNullException(nameof(key)); } _thenByList.Add(new ThenByEntry(key)); return this; }
public Meta(string key, DocumentConfig metadata) { if (key == null) { throw new ArgumentNullException(nameof(key)); } _key = key; _metadata = metadata ?? ((x, y) => null); }
/// <summary> /// Reads all files that match the specified globbing patterns and/or absolute paths. This allows you to /// specify different patterns and/or paths depending on the input. /// </summary> /// <param name="patterns">A delegate that returns one or more globbing patterns and/or absolute paths.</param> public ReadFiles(DocumentConfig patterns) { if (patterns == null) { throw new ArgumentNullException(nameof(patterns)); } _patternsDelegate = patterns; }
/// <summary> /// Reads all files that match the specified path. This allows you to specify different search paths depending on the input. /// </summary> /// <param name="path">A delegate that returns a <c>string</c> with the search path.</param> public ReadFiles(DocumentConfig path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } _path = path; }
/// <summary> /// Copies all files that match the specified path. This allows you to specify different search paths depending on the input document. /// </summary> /// <param name="sourcePath">A delegate that returns a <c>string</c> with the desired search path.</param> public CopyFiles(DocumentConfig sourcePath) { if (sourcePath == null) { throw new ArgumentNullException(nameof(sourcePath)); } _sourcePath = sourcePath; }
/// <summary> /// Copies all files that match the specified search pattern. /// </summary> /// <param name="searchPattern">The search pattern to use.</param> public CopyFiles(string searchPattern) { if (searchPattern == null) { throw new ArgumentNullException(nameof(searchPattern)); } _sourcePath = (x, y) => searchPattern; }
public GroupBy(DocumentConfig key, params IModule[] modules) { if (key == null) { throw new ArgumentNullException(nameof(key)); } _key = key; _modules = modules; }
/// <summary> /// Searches for sidecar files at the same path as the input document SourceFilePath with the specified additional extension. /// If a sidecar file is found, it's content is passed to the specified child modules for processing. /// </summary> /// <param name="extension">The extension to search.</param> /// <param name="modules">The modules to execute against the sidecar file.</param> public Sidecar(string extension, params IModule[] modules) { if (string.IsNullOrEmpty(extension)) { throw new ArgumentException("Value cannot be null or empty.", nameof(extension)); } _sidecarPath = (d, c) => d.FilePath(Keys.SourceFilePath)?.AppendExtension(extension); _modules = modules; }
/// <summary> /// Uses a delegate to describe where to find the sidecar file for each input document. /// If a sidecar file is found, it's content is passed to the specified child modules for processing. /// </summary> /// <param name="sidecarPath">A delegate that returns a <see cref="FilePath"/> with the desired sidecar path.</param> /// <param name="modules">The modules to execute against the sidecar file.</param> public Sidecar(DocumentConfig sidecarPath, params IModule[] modules) { if (sidecarPath == null) { throw new ArgumentNullException(nameof(sidecarPath)); } _sidecarPath = sidecarPath; _modules = modules; }
/// <summary> /// Uses a delegate to describe where to write the content of each document. /// The output of the function should be either a full path to the disk /// location (including file name) or a path relative to the output folder. /// </summary> /// <param name="path">A delegate that returns a <c>string</c> with the desired path.</param> public WriteFiles(DocumentConfig path) { if (path == null) { throw new ArgumentNullException(nameof(path)); } _path = path; _warnOnWriteMetadata = true; }
/// <summary> /// Partitions the result of the specified modules into groups with matching keys /// based on the value at the specified metadata key. /// If a document to group does not contain the specified metadata key, it is not included in any output groups. /// The input documents to GroupBy are used as /// the initial input documents to the specified modules. /// </summary> /// <param name="keyMetadataKey">The key metadata key.</param> /// <param name="modules">Modules to execute on the input documents prior to grouping.</param> public GroupBy(string keyMetadataKey, params IModule[] modules) { if (keyMetadataKey == null) { throw new ArgumentNullException(nameof(keyMetadataKey)); } _key = (doc, ctx) => doc.Get(keyMetadataKey); _modules = modules; _predicate = (doc, ctx) => doc.ContainsKey(keyMetadataKey); }
/// <summary> /// Sets the metadata key <c>WriteFileName</c> to an optimized version of the specified input metadata key. /// Also sets the metadata key <c>WritePath</c> to <c>Path.Combine(RelativeFileDir, WriteFileName)</c>. /// </summary> /// <param name="inputKey">The metadata key to use for the input filename.</param> public FileName(string inputKey) { if (inputKey == null) { throw new ArgumentNullException(nameof(inputKey)); } if (string.IsNullOrWhiteSpace(inputKey)) { throw new ArgumentException(nameof(inputKey)); } _fileName = (d, c) => d.String(inputKey); }
public WriteFiles(string extension) { if (extension == null) { throw new ArgumentNullException(nameof(extension)); } _path = (x, y) => { string fileRelative = x.String(MetadataKeys.RelativeFilePath); if (!string.IsNullOrWhiteSpace(fileRelative)) { return Path.ChangeExtension(fileRelative, extension); } return null; }; }
/// <summary> /// Specifies a model to use for each page. /// </summary> /// <param name="model">The model.</param> /// <returns>The current module instance.</returns> public Razor WithModel(object model) { _model = (doc, ctx) => model; return(this); }
public Prepend(DocumentConfig content) : base(content) { }
/// <summary> /// Transforms input documents using a specified XSLT file from the file system. /// </summary> /// <param name="xsltPath">The path of the XSLT file to use.</param> public Xslt(string xsltPath) { _xsltPath = (a, b) => xsltPath; }
/// <summary> /// Specifies a model to use for each page based on the current input /// document and context. /// </summary> /// <param name="model">A delegate that returns the model.</param> /// <returns>The current module instance.</returns> public Razor WithModel(DocumentConfig model) { _model = model; return(this); }
/// <summary> /// Sets the item identifier. The default value is the absolute link to the input document. /// </summary> /// <param name="itemId">A delegate that should return a <c>Uri</c> with /// the item identifier.</param> public GenerateFeeds WithItemId(DocumentConfig itemId) { _itemId = itemId; return(this); }
/// <summary> /// Sets the item published time. The default value is the value for the "Published" key /// in the input document. /// </summary> /// <param name="itemPublished">A delegate that should return a <c>DateTime</c> with /// the item published time.</param> public GenerateFeeds WithItemPublished(DocumentConfig itemPublished) { _itemPublished = itemPublished; return(this); }
/// <summary> /// Uses a delegate to describe where to write the content of each document. /// The output of the function should be either a full path to the disk /// location (including file name) or a path relative to the output folder. /// </summary> /// <param name="path">A delegate that returns a <c>string</c> with the desired path.</param> public UnwrittenFiles(DocumentConfig path) : base(path) { }
/// <summary> /// Specifies an alternate ViewStart file to use for all Razor pages processed by this module. /// </summary> /// <param name="path">The path to the alternate ViewStart file.</param> /// <returns>The current module instance.</returns> public Razor WithViewStart(FilePath path) { _viewStartPath = (doc, ctx) => path; return(this); }
/// <summary> /// Specifies an alternate ViewStart file to use for all Razor pages processed by this module. This /// lets you specify a different ViewStart file for each document. For example, you could return a /// ViewStart based on document location or document metadata. Returning <c>null</c> from the /// function reverts back to the default ViewStart search behavior for that document. /// </summary> /// <param name="path">A delegate that should return the ViewStart path as a <c>FilePath</c>, /// or <c>null</c> for the default ViewStart search behavior.</param> /// <returns>The current module instance.</returns> public Razor WithViewStart(DocumentConfig path) { _viewStartPath = path; return(this); }
public MethodConfig(IMethodImpl methodImpl, MethodDef methodDef, MethodType type, DocumentConfig documentConfig, IRegion region = null) : this(methodImpl, methodDef, type, documentConfig, region, false) { }
public MetaFileEntry(DocumentConfig metadataFileName, bool inherited, bool replace) { MetadataFileName = metadataFileName; Inherited = inherited; Replace = replace; }
public static T Invoke <T>(this DocumentConfig config, IDocument document, IExecutionContext context) { return(Invoke <T>(config, document, context, null)); }
/// <summary> /// Reads the project file at the specified path. This allows you to specify a different project file depending on the input. /// </summary> /// <param name="path">A delegate that returns a <c>FilePath</c> with the project file path.</param> public ReadProject(DocumentConfig path) : base(path) { }
/// <summary> /// Uses the string value of the returned object as the new content for each document. This /// allows you to specify different content for each document depending on the input document. /// </summary> /// <param name="content">A delegate that gets the new content to use.</param> public Content(DocumentConfig content) : base(content) { }
/// <summary> /// Sets the item thread count. By default, no thread count is specified. /// </summary> /// <param name="itemThreadCount">A delegate that should return an <c>int</c> with /// the item thread count.</param> public GenerateFeeds WithItemThreadCount(DocumentConfig itemThreadCount) { _itemThreadCount = itemThreadCount; return(this); }
/// <summary> /// Specifies a layout file to use for all Razor pages processed by this module. /// </summary> /// <param name="path">The path to the layout file.</param> /// <returns>The current module instance.</returns> public Razor WithLayout(FilePath path) { _layoutPath = (doc, ctx) => path; return(this); }
/// <summary> /// Sets the item thread link. By default, no thread link is specified. /// </summary> /// <param name="itemThreadLink">A delegate that should return a <c>Uri</c> with /// the item thread link.</param> public GenerateFeeds WithItemThreadLink(DocumentConfig itemThreadLink) { _itemThreadLink = itemThreadLink; return(this); }
public UnwrittenFiles(DocumentConfig path) : base(path) { }
/// <summary> /// Sets the item author. The default value is the value for the "Author" key /// in the input document. /// </summary> /// <param name="itemAuthor">A delegate that should return a <c>string</c> with /// the item author.</param> public GenerateFeeds WithItemAuthor(DocumentConfig itemAuthor) { _itemAuthor = itemAuthor; return(this); }
/// <summary> /// The object stored in metadata at the specified key is converted to JSON, which then either /// replaces the content of each input document or is stored in the specified metadata key. /// </summary> /// <param name="sourceKey">The metadata key of the object to convert to JSON.</param> /// <param name="destinationKey">The metadata key where the JSON should be stored (or <c>null</c> /// to replace the content of each input document).</param> public GenerateJson(string sourceKey, string destinationKey = null) { _destinationKey = destinationKey; _data = (doc, ctx) => doc.Get(sourceKey); }
/// <summary> /// Sets the item description. The default value is the value for the "Description" key /// in the input document. /// </summary> /// <param name="itemDescription">A delegate that should return a <c>string</c> with /// the item description.</param> public GenerateFeeds WithItemDescription(DocumentConfig itemDescription) { _itemDescription = itemDescription; return(this); }
/// <summary> /// The object returned by the specified delegate is converted to JSON, which then either /// replaces the content of each input document or is stored in the specified metadata key. /// </summary> /// <param name="data">A delegate that returns the object to convert to JSON.</param> /// <param name="destinationKey">The metadata key where the JSON should be stored (or <c>null</c> /// to replace the content of each input document).</param> public GenerateJson(DocumentConfig data, string destinationKey = null) { _data = data; }
/// <summary> /// Sets the item title. The default value is the value for the "Title" key /// in the input document. /// </summary> /// <param name="itemTitle">A delegate that should return a <c>string</c> with /// the item title.</param> public GenerateFeeds WithItemTitle(DocumentConfig itemTitle) { _itemTitle = itemTitle; return(this); }
/// <summary> /// Transforms input documents using a specified XSLT file from the file system /// as provided by a delegate. This allows you to use different XSLT files depending /// on the input document. /// </summary> /// <param name="xsltPath">A delegate that should return the path of the XSLT file to use.</param> public Xslt(DocumentConfig xsltPath) { _xsltPath = xsltPath; }
protected ContentModule(DocumentConfig content) { _content = new ConfigHelper<object>(content); }
/// <summary> /// Specifies a file name to use as common metadata using a delegate so that the common metadata document can be specific to the input document. /// </summary> /// <param name="metadataFileName">A delegate that returns a <c>bool</c> indicating if the current document contains the metadata you want to use.</param> /// <param name="inherited">If set to <c>true</c>, metadata from documents with this file name will be inherited by documents in nested directories.</param> /// <param name="replace">If set to <c>true</c>, metadata from this document will replace any existing metadata on the target document.</param> /// <returns>The current module instance.</returns> public DirectoryMeta WithMetadataFile(DocumentConfig metadataFileName, bool inherited = false, bool replace = false) { _metadataFile.Add(new MetaFileEntry(metadataFileName, inherited, replace)); return(this); }
/// <summary> /// Specifies the predicate to use for filtering documents. /// Only input documents for which the predicate returns <c>true</c> will be output. /// </summary> /// <param name="predicate">A predicate delegate that should return a <c>bool</c>.</param> public Where(DocumentConfig predicate) { _predicate = predicate; }
/// <summary> /// Outputs the string value of the returned object to trace. This allows /// you to trace different content for each document depending on the input document. /// </summary> /// <param name="content">A delegate that returns the content to trace.</param> public Trace(DocumentConfig content) : base(content) { }
/// <summary> /// The object returned by the specified delegate is converted to JSON, which then either /// replaces the content of each input document or is stored in the specified metadata key. /// </summary> /// <param name="data">A delegate that returns the object to convert to JSON.</param> /// <param name="destinationKey">The metadata key where the JSON should be stored (or <c>null</c> /// to replace the content of each input document).</param> public GenerateJson(ContextConfig data, string destinationKey = null) { _data = (doc, ctx) => data(ctx); }
/// <summary> /// Specifies a delegate that should be used to get the input path for each /// input document. This allows the Sass processor to search the right /// file system and paths for include files. By default, the <see cref="Keys.RelativeFilePath"/> /// metadata value is used for the input document path. /// </summary> /// <param name="inputPath">A delegate that should return a <see cref="FilePath"/>.</param> /// <returns>The current instance.</returns> public Sass WithInputPath(DocumentConfig inputPath) { _inputPath = inputPath ?? throw new ArgumentNullException(nameof(inputPath)); return(this); }
/// <summary> /// Specifies an alternate condition to be tested on documents that did not satisfy /// previous conditions. You can chain together as many <c>ElseIf</c> calls as needed. /// </summary> /// <param name="predicate">A predicate delegate that should return a <c>bool</c>.</param> /// <param name="modules">The modules to execute on documents where the predicate is <c>true</c>.</param> public If ElseIf(DocumentConfig predicate, params IModule[] modules) { _conditions.Add(new Tuple <DocumentConfig, IModule[]>(predicate, modules)); return(this); }
/// <summary> /// Partitions the result of the specified modules into groups with matching keys /// based on the key delegate. /// The input documents to GroupBy are used as /// the initial input documents to the specified modules. /// </summary> /// <param name="key">A delegate that returns the group keys.</param> /// <param name="modules">Modules to execute on the input documents prior to grouping.</param> public GroupByMany(DocumentConfig key, params IModule[] modules) : this(key, (IEnumerable <IModule>)modules) { }
/// <summary> /// Appends the string value of the returned object to to content of each document. /// This allows you to specify different content to append for each document depending /// on the input document. /// </summary> /// <param name="content">A delegate that returns the content to append.</param> public Append(DocumentConfig content) : base(content) { }
/// <summary> /// Sets the item thread updated. By default, no thread updated time is specified. /// </summary> /// <param name="itemThreadUpdated">A delegate that should return a <c>DateTime</c> with /// the item thread updated time.</param> public GenerateFeeds WithItemThreadUpdated(DocumentConfig itemThreadUpdated) { _itemThreadUpdated = itemThreadUpdated; return(this); }
private MethodConfig(IMethodImpl methodImpl, MethodDef methodDef, MethodType type, DocumentConfig documentConfig, IRegion region, bool isTokenOverload) { Method = methodImpl; MethodDef = methodDef; MethodType = type; if (region != null && region.Type != MethodType.Unspecified) { MethodType = region.Type; } DocumentConfig = documentConfig; this.region = region; CalculateCancellationTokenMode(isTokenOverload); }
/// <summary> /// Specifies a layout file to use for all Razor pages processed by this module. This /// lets you specify a different layout file for each document. /// </summary> /// <param name="path">A delegate that should return the layout path as a <c>FilePath</c>.</param> /// <returns>The current module instance.</returns> public Razor WithLayout(DocumentConfig path) { _layoutPath = path; return(this); }