Example #1
0
        void FormatStyle(Style style, StyleFormatType formatType, StringBuilder builder)
        {
            if (this.StyleSheet == null)
            {
                return;
            }

            foreach (var entry in style)
            {
                TwineTMProStyle styleFormat = StyleSheet.Styles
                                              .Where((System.Func <TwineTMProStyle, bool>)(f => (bool)(f.MatchingKeys.Contains(entry.Key) &&
                                                                                                       (
                                                                                                           string.IsNullOrEmpty(f.MatchingValuesRegex) ||
                                                                                                           CheckRegex(f, entry.Value)
                                                                                                       )))
                                                     )
                                              .FirstOrDefault();

                if (styleFormat == null)
                {
                    continue;
                }

                string format = formatType == StyleFormatType.Prefix ?
                                styleFormat.Prefix :
                                styleFormat.Suffix;

                if (format == null)
                {
                    continue;
                }

                builder.AppendFormat(Unescape(format), entry.Value);
            }
        }
Example #2
0
 private static bool CheckRegex(TwineTMProStyle f, object value)
 {
     return(Regex.IsMatch(System.Convert.ToString(value), f.MatchingValuesRegex));
 }