Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
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 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));
        }
Ejemplo n.º 3
0
        /// <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);
            }
        }
Ejemplo n.º 4
0
 /// <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);
 }
Ejemplo n.º 5
0
 /// <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);
 }
Ejemplo n.º 6
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);
Ejemplo n.º 7
0
 /// <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);
Ejemplo n.º 8
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>
 public string Process(TextSubstitutionContext context)
 {
     return(ProcessCore(context));
 }
Ejemplo n.º 9
0
 /// <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));
 }