/// <summary> /// Registers a highlighter. /// </summary> /// <param name="highlighter">Highlighter instance to be registered.</param> /// <param name="extensions">File extensions the file highighter applies to.</param> public static void RegisterFileHighlighter(IHighlighter highlighter, params string[] extensions) { if (highlighter == null) { return; } sFileHighlighterTypes[highlighter.GetType().Name] = highlighter.GetType(); foreach (var extension in extensions) { sFileHighlighters[extension] = highlighter; } }
/// <summary> /// Unregisters a highlighter. /// </summary> /// <param name="highlighter">Highlighter instance, which should be unregistered.</param> public static void UnregisterFileHighlighter(IHighlighter highlighter) { if (highlighter == null) { return; } sFileHighlighterTypes.Remove(highlighter.GetType().Name); foreach (var extensionToUnregister in sFileHighlighters.Where(registeredFileHighlighter => registeredFileHighlighter.Value == highlighter).Select(registeredFileHighlighter => registeredFileHighlighter.Key).ToList()) { sFileHighlighters.Remove(extensionToUnregister); } }
/// <summary> /// Configures the specified highlighter according to the specified highlighter configuration. /// </summary> /// <param name="highlighter">Highlighter, which should be configured.</param> /// <param name="highlighterConfiguration">Highlighter configuration.</param> private static void ConfigureHighlighter(IHighlighter highlighter, object highlighterConfiguration) { if (highlighter != null) { try { var configureMethod = highlighter.GetType().GetMethod(CONFIGURE_METHOD_NAME); if (configureMethod != null) { configureMethod.Invoke(highlighter, new object[] { highlighterConfiguration }); } } catch { } } }