protected virtual void ApplyConfig(TextTransformerConfig config)
        {
            if (config == null)
            {
                return;
            }

            if (config.TokensRegex != null)
            {
                this.TokensRegex = config.TokensRegex;
            }

            if (config.VariablesRegex != null)
            {
                this.VarsRegex = config.VariablesRegex;
            }

            if (config.AnchorsRegex != null)
            {
                this.AnchorsRegex = config.AnchorsRegex;
            }

            if (config.Selectors != null)
            {
                foreach (string key in config.Selectors.Keys)
                {
                    this.Selectors.Add(key, config.Selectors[key]);
                }
            }

            if (config.Variables != null)
            {
                foreach (string key in config.Variables.Keys)
                {
                    this.Variables.Add(key, config.Variables[key]);
                }
            }

            if (config.DefaultTemplates != null)
            {
                foreach (string key in config.DefaultTemplates.Keys)
                {
                    this.DefaultTemplates.Add(key, config.DefaultTemplates[key]);
                }
            }

            if (config.TokensType != null)
            {
                this.TokensType.AddRange(config.TokensType);
            }

            if (config.SkipValidation.HasValue)
            {
                this.SkipValidation = config.SkipValidation.Value;
            }
        }
        protected virtual void ApplyConfig(TextTransformerConfig config)
        {
            if (config == null)
            {
                return;
            }

            if (config.TokensRegex != null)
            {
                this.TokensRegex = config.TokensRegex;
            }

            if (config.VariablesRegex != null)
            {
                this.VarsRegex = config.VariablesRegex;
            }

            if (config.AnchorsRegex != null)
            {
                this.AnchorsRegex = config.AnchorsRegex;
            }

            if (config.Selectors != null)
            {
                foreach (string key in config.Selectors.Keys)
                {
                    this.Selectors.Add(key, config.Selectors[key]);
                }
            }

            if (config.Variables != null)
            {
                foreach (string key in config.Variables.Keys)
                {
                    this.Variables.Add(key, config.Variables[key]);
                }
            }

            if (config.DefaultTemplates != null)
            {
                foreach (string key in config.DefaultTemplates.Keys)
                {
                    this.DefaultTemplates.Add(key, config.DefaultTemplates[key]);
                }
            }

            if (config.TokensType != null)
            {
                this.TokensType.AddRange(config.TokensType);
            }

            if (config.SkipValidation.HasValue)
            {
                this.SkipValidation = config.SkipValidation.Value;
            }
        }
 public TextTransformer(string text, TextTransformerConfig config) : this(text)
 {
     this.ApplyConfig(config);
 }
 public static string Transform(string text, TextTransformerConfig config)
 {
     return new Transformer.NET.TextTransformer(text, config).Transform();
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="text"></param>
 /// <param name="config"></param>
 public ExtNetTransformer(string text, TextTransformerConfig config)
     : base(text, config)
 {
     this.InitSelectors();
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="text"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 new public static string Transform(string text, TextTransformerConfig config)
 {
     return new ExtNetTransformer(ExtNetTransformer.PrepareText(text), config).Transform();
 }
Beispiel #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="text"></param>
 /// <param name="config"></param>
 /// <returns></returns>
 public static string Transform(string text, TextTransformerConfig config)
 {
     return(Transformer.NET.TextTransformer.Transform(text, config));
 }
 public TextTransformer(string text, TextTransformerConfig config) : this(text)
 {
     this.ApplyConfig(config);
 }