Skip to content

CommunitySearch

Namespace Nfty.Core.Publish.Community in assembly Nfty.Core.

public static class CommunitySearch

The one search box: #tag, @user and plain words, combined with AND. The text is the only source of truth, so clicking a tag chip, a tile's owner or a tag link just edits the text with CommunitySearch.Toggle().

Methods

Has(string?, string)

public static bool Has(string? text, string token);

Whether the text carries token as one of its terms (ignoring case).

Parameters

  • text (string?) - The box's text.
  • token (string) - The token.

Returns. True when the token is one of the terms.

Matches(CommunityEntry, CommunityQuery)

public static bool Matches(CommunityEntry entry, CommunityQuery query);

Whether an entry satisfies every term of the query. An empty query matches everything.

Parameters

  • entry (CommunityEntry) - The entry.
  • query (CommunityQuery) - The parsed search.

Returns. True when the entry satisfies every term.

Parse(string?)

public static CommunityQuery Parse(string? text);

Splits the box's text on whitespace into tags, owners and words. A lone # or @ is ignored.

Parameters

  • text (string?) - What the user typed; null reads as empty.

Returns. The tags, owners and words the text names.

Toggle(string?, string)

public static string Toggle(string? text, string token);

Adds token to the text when it is not there, removes it when it is, and leaves single spaces.

Parameters

  • text (string?) - The box's text.
  • token (string) - The token, such as #pets or @alice. Compared ignoring case.

Returns. The text with the token added or removed.