public void ApplyConfig(UserConfig userConfig) { if (userConfig == null) { throw new ArgumentNullException("userConfig"); } NickColors = (bool)userConfig["Interface/Notebook/Channel/NickColors"]; StripColors = (bool)userConfig["Interface/Notebook/StripColors"]; StripFormattings = (bool)userConfig["Interface/Notebook/StripFormattings"]; HighlightColor = TextColor.Parse( (string)userConfig["Interface/Notebook/Tab/HighlightColor"] ); HighlightWords = new List <string>( (string[])userConfig["Interface/Chat/HighlightWords"] ); var patternController = new MessagePatternListController(userConfig); var userPatterns = patternController.GetList(); var builtinPatterns = BuiltinPatterns; var patterns = new List <MessagePatternModel>(builtinPatterns.Count + userPatterns.Count); // No need to lock BuiltinPatterns as List<T> is thread-safe for // multiple readers as long as there is no writer at the same time. // BuiltinPatterns is only written once before the first instance // of MessageBuilderSettings is created via the static initializer. patterns.AddRange(builtinPatterns); patterns.AddRange(userPatterns); Patterns = patterns; UserPatterns = userPatterns; }
public void ApplyConfig(UserConfig userConfig) { if (userConfig == null) { throw new ArgumentNullException("userConfig"); } NickColors = (bool)userConfig["Interface/Notebook/Channel/NickColors"]; StripColors = (bool)userConfig["Interface/Notebook/StripColors"]; StripFormattings = (bool)userConfig["Interface/Notebook/StripFormattings"]; HighlightColor = TextColor.Parse( (string)userConfig["Interface/Notebook/Tab/HighlightColor"] ); HighlightWords = new List <string>( (string[])userConfig["Interface/Chat/HighlightWords"] ); Emojis = (bool)userConfig["Interface/Chat/Emojis"]; var patternController = new MessagePatternListController(userConfig); var userPatterns = patternController.GetList(); var builtinPatterns = BuiltinPatterns; var patterns = new List <MessagePatternModel>(builtinPatterns.Count + userPatterns.Count); // No need to lock BuiltinPatterns as List<T> is thread-safe for // multiple readers as long as there is no writer at the same time. // BuiltinPatterns is only written once before the first instance // of MessageBuilderSettings is created via the static initializer. patterns.AddRange(builtinPatterns); patterns.AddRange(userPatterns); if (Emojis) { // Emoji var regex = new Regex(@":(\w+):", RegexOptions.Compiled); patterns.Add(new MessagePatternModel(regex) { MessagePartType = typeof(ImageMessagePartModel), LinkFormat = "smuxi-emoji://{1}", }); } Patterns = patterns; UserPatterns = userPatterns; }
public void ApplyConfig(UserConfig userConfig) { if (userConfig == null) { throw new ArgumentNullException("userConfig"); } NickColors = (bool) userConfig["Interface/Notebook/Channel/NickColors"]; StripColors = (bool) userConfig["Interface/Notebook/StripColors"]; StripFormattings = (bool) userConfig["Interface/Notebook/StripFormattings"]; HighlightColor = TextColor.Parse( (string) userConfig["Interface/Notebook/Tab/HighlightColor"] ); HighlightWords = new List<string>( (string[]) userConfig["Interface/Chat/HighlightWords"] ); var patternController = new MessagePatternListController(userConfig); var userPatterns = patternController.GetList(); var builtinPatterns = BuiltinPatterns; var patterns = new List<MessagePatternModel>(builtinPatterns.Count + userPatterns.Count); // No need to lock BuiltinPatterns as List<T> is thread-safe for // multiple readers as long as there is no writer at the same time. // BuiltinPatterns is only written once before the first instance // of MessageBuilderSettings is created via the static initializer. patterns.AddRange(builtinPatterns); patterns.AddRange(userPatterns); Patterns = patterns; UserPatterns = userPatterns; }
public void ApplyConfig(UserConfig userConfig) { if (userConfig == null) { throw new ArgumentNullException("userConfig"); } NickColors = (bool) userConfig["Interface/Notebook/Channel/NickColors"]; StripColors = (bool) userConfig["Interface/Notebook/StripColors"]; StripFormattings = (bool) userConfig["Interface/Notebook/StripFormattings"]; HighlightColor = TextColor.Parse( (string) userConfig["Interface/Notebook/Tab/HighlightColor"] ); HighlightWords = new List<string>( (string[]) userConfig["Interface/Chat/HighlightWords"] ); Emojis = (bool) userConfig["Interface/Chat/Emojis"]; var patternController = new MessagePatternListController(userConfig); var userPatterns = patternController.GetList(); var builtinPatterns = BuiltinPatterns; var patterns = new List<MessagePatternModel>(builtinPatterns.Count + userPatterns.Count); // No need to lock BuiltinPatterns as List<T> is thread-safe for // multiple readers as long as there is no writer at the same time. // BuiltinPatterns is only written once before the first instance // of MessageBuilderSettings is created via the static initializer. patterns.AddRange(builtinPatterns); patterns.AddRange(userPatterns); if (Emojis) { // Emoji var regex = new Regex(@":(\w+):", RegexOptions.Compiled); patterns.Add(new MessagePatternModel(regex) { MessagePartType = typeof(ImageMessagePartModel), LinkFormat = "smuxi-emoji://{1}", }); } Patterns = patterns; UserPatterns = userPatterns; }