42 lines
1.3 KiB
C#
42 lines
1.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Text.RegularExpressions;
|
|||
|
|
|
|||
|
|
namespace DBToolControls {
|
|||
|
|
public class SyntaxProvider {
|
|||
|
|
private static List<char> delimiters = new List<char>() { ' ', '\r', '\n', '\t', '(', ')', ';', ',', '.' };
|
|||
|
|
public static ICollection<char> Delimiters {
|
|||
|
|
get { return delimiters; }
|
|||
|
|
}
|
|||
|
|
public static string DelimitersAsRegExPattern {
|
|||
|
|
get {
|
|||
|
|
StringBuilder sb = new StringBuilder("(\\r\\n", 32);
|
|||
|
|
foreach (char c in delimiters)
|
|||
|
|
sb.AppendFormat("|{0}", Regex.Escape(c.ToString()));
|
|||
|
|
return sb.Append(")").ToString();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private List<Syntax> syntaxes = new List<Syntax>();
|
|||
|
|
|
|||
|
|
// Constructor
|
|||
|
|
public SyntaxProvider() {
|
|||
|
|
syntaxes = new List<Syntax>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Mehods
|
|||
|
|
public void AddSyntax(Syntax item) {
|
|||
|
|
syntaxes.Add(item);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public Dictionary<DependencyProperty, object> GetFormattingFor(string wordToFormat) {
|
|||
|
|
foreach (Syntax sy in syntaxes)
|
|||
|
|
if (sy.Contains(wordToFormat)) return sy.PropertyValues;
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|