// -------------------------------------------------------------------------------------------------------------------- // // Copyright (c) James South. // Licensed under the Apache License, Version 2.0. // // // Encapsulates methods to control preservation of meta information. // // -------------------------------------------------------------------------------------------------------------------- namespace ImageProcessor.Web.Processors { using System.Text.RegularExpressions; using ImageProcessor.Processors; /// /// Encapsulates methods to control preservation of meta information. /// public class Meta : IWebGraphicsProcessor { /// /// The regular expression to search strings for. /// private static readonly Regex QueryRegex = new Regex(@"meta=(true|false)", RegexOptions.Compiled); /// /// Initializes a new instance of the class. /// public Meta() { this.Processor = new ImageProcessor.Processors.Meta(); } /// /// Gets the regular expression to search strings for. /// public Regex RegexPattern { get { return QueryRegex; } } /// /// Gets the order in which this processor is to be used in a chain. /// public int SortOrder { get; private set; } /// /// Gets the associated graphics processor. /// public IGraphicsProcessor Processor { get; private set; } /// /// The position in the original string where the first character of the captured substring was found. /// /// /// The query string to search. /// /// /// The zero-based starting position in the original string where the captured substring was found. /// public int MatchRegexIndex(string queryString) { this.SortOrder = int.MaxValue; Match match = this.RegexPattern.Match(queryString); if (match.Success) { this.SortOrder = match.Index; bool preserve = bool.Parse(match.Value.Split('=')[1]); this.Processor.DynamicParameter = preserve; } return this.SortOrder; } } }