Regextra.Template.Format C# (CSharp) Méthode

Format() public static méthode

public static Format ( string template, object item, IFormatProvider provider = null ) : string
template string
item object
provider IFormatProvider
Résultat string
        public static string Format(string template, object item, IFormatProvider provider = null)
        {
            var result = _templateRegex.Replace(template, m =>
            {
                if (IsBalancedDelimiterCountEven(m))
                {
                    return FormatEscapedToken(m.Value);
                }

                if (IsBalancedDelimiterCountOdd(m))
                {
                    string property = GetMatchPropertyValue(item, m, provider);
                    return FormatOddBalancedToken(m, property);
                }

                if (IsPartiallyDelimited(m))
                {
                    Func<string> propertyValue = () => GetMatchPropertyValue(item, m, provider);
                    return FormatPartiallyDelimitedToken(m, propertyValue);
                }

                return m.Value;
            });

            return result;
        }