/// <summary>Determines if the rule can process the context.</summary> /// <param name="context">The context to check.</param> /// <returns><see langword="true"/> if the rule applies.</returns> protected override bool CanProcessCore(TextSubstitutionContext context) { EnsureCacheInitialized(context.Options); //See if the context exists as a member m_member = FindMember(context.Text); return(m_member != null); }
/// <summary>Processes the current context and returns the new text.</summary> /// <param name="context">The context to check.</param> /// <returns>The updated text.</returns> protected override string ProcessCore(TextSubstitutionContext context) { EnsureCacheInitialized(context.Options); //Just in case somebody calls Process directly we'll ignore the request m_member = m_member ?? FindMember(context.Text); if (m_member == null) { return(null); } //Get the string value return(GetMemberValue(m_member)); }
/// <summary>Called to process delimited text.</summary> /// <param name="context">The processing context.</param> /// <param name="tokenInfo">The token being processed.</param> /// <remarks> /// The default implementation returns the replacement obj from the corresponding substitution rule. /// </remarks> protected virtual void OnProcessDelimitedText(TextSubstitutionProcessContext context, TextTokenInfo tokenInfo) { //Process the template and output whatever results var subContext = new TextSubstitutionContext(context.Options, tokenInfo.OriginalText); //Find the applicable rule var rule = (from r in Rules where r.CanProcess(subContext) select r).FirstOrDefault(); //Get the new text var text = (rule != null) ? rule.Process(subContext) : OnHandleRuleNotFound(context, tokenInfo); //Output if (!String.IsNullOrEmpty(text)) { context.Output.Append(text); } }
/// <summary>Determines if a rule matches the context.</summary> /// <param name="context">The context to check.</param> /// <returns>The updated text.</returns> protected override string ProcessCore(TextSubstitutionContext context) { return(ReplacementText); }
/// <summary>Determines if the rule can process the context.</summary> /// <param name="context">The context to check.</param> /// <returns><see langword="true"/> if the rule applies.</returns> protected override bool CanProcessCore(TextSubstitutionContext context) { return(String.Compare(context.Text, MatchingText, context.Options.Comparison) == 0); }
/// <summary>Processes the current context and returns the new text.</summary> /// <param name="context">The context to check.</param> /// <returns>The updated text.</returns> protected abstract string ProcessCore(TextSubstitutionContext context);
/// <summary>Determines if the rule can process the context.</summary> /// <param name="context">The context to check.</param> /// <returns><see langword="true"/> if the rule applies.</returns> protected abstract bool CanProcessCore(TextSubstitutionContext context);
/// <summary>Processes the current context and returns the new text.</summary> /// <param name="context">The context to check.</param> /// <returns>The updated text.</returns> public string Process(TextSubstitutionContext context) { return(ProcessCore(context)); }
/// <summary>Determines if the rule can process the context.</summary> /// <param name="context">The context to check.</param> /// <returns><see langword="true"/> if the rule applies.</returns> public bool CanProcess(TextSubstitutionContext context) { return(CanProcessCore(context)); }