SnippetServer

public static class SnippetServer
Maintains all loaded snippets.

Properties

Folders

#
public static IEnumerable<string> Folders { get; }
Gets all folders currently tracked by this server.

Snippets

#
public static IEnumerable<Snippet> Snippets { get; }
Gets all folders currently tracked by this server.

UserCount

#
public static int UserCount { get; }
Gets the number of snippets across all user folders. Snippets shipped with the installation are not counted.

UserSnippets

#
public static IEnumerable<Snippet> UserSnippets { get; }
Gets all snippets which come from user folders, i.e. folders added with isUser: true. Snippets shipped with the installation are excluded.

Methods

AddFolder

#
public static void AddFolder(string folder, bool isUser)
Add a folder containing snippets to this server. The folder is scanned for *.ghz files and a watcher is installed to keep the snippet list in sync with the file system. Duplicate folders are silently ignored.
folder (string)Folder to scan.
isUser (bool)True if this folder holds user-authored snippets. Folders shipped with the installation should pass false so they can be excluded from the user-only enumerator.

FindById

#
public static Snippet FindById(Guid id)
Look up a tracked snippet by its Snippet.Id. Returns null if no match is found.
id (Guid)

RemoveFolder

#
public static bool RemoveFolder(string folder)
Remove a folder from this server. Its watcher is disposed and its tracked snippets are forgotten.
folder (string)
True if the folder was being tracked and has now been removed.

Search

#
public static void Search(string[] queryFragments, MaximumSearchMultiple<object> results)
Search all snippets and append them to a result.
queryFragments (string[])Clean search query terms.
results (Maths.MaximumSearchMultiple<object>)Result to append Snippet instances to.

Events

SnippetsChanged

#
public static event EventHandler SnippetsChanged
Raised whenever the tracked folder list changes, or any folder's snippet list changes.