Beamable SDK
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Static Protected Member Functions | Static Protected Attributes | List of all members
Beamable.Common.Content.ContentQuery Class Reference

A ContentQuery allows you to construct a complex statement that selects specific content by type, tag, or id. More...

Inheritance diagram for Beamable.Common.Content.ContentQuery:
Inheritance graph
[legend]
Collaboration diagram for Beamable.Common.Content.ContentQuery:
Collaboration graph
[legend]

Public Member Functions

 ContentQuery (ContentQuery other)
 The copy-constructor for a ContentQuery More...
 
virtual bool Accept (IContentObject content)
 Check if the given IContentObject meets the tag, type, and id constraints. Tags are AND based, so the content must have ALL tags in the TagConstraints field. Types are OR based, so the content type only needs to be one of the types specified in the TypeConstraints field. This check allows subtypes of types in the TypeConstraints to be accepted. The id constraint is a substring match, so as long as the content's id contains the DefaultQuery.IdContainsConstraint , the id constraint passes. More...
 
bool AcceptTag (IContentObject content)
 Check if the given IContentObject meets the tag constraint. Tags are AND based, so the content must have ALL tags in the TagConstraints field. More...
 
bool AcceptTags (HashSet< string > tags)
 Check if the given set of tags would meet the tag constraint. Tags are AND based, so the given set of tags must have ALL tags in the TagConstraints field. More...
 
bool AcceptType< TContent > (bool allowInherit=true)
 Check if the given generic content type passes the type constraint. Types are OR based, so the content type only needs to be one of the types specified in the TypeConstraints field. More...
 
bool AcceptType (Type type, bool allowInherit=true)
 Check if the given runtime type passes the type constraint Types are OR based, so the content type only needs to be one of the types specified in the TypeConstraints field. More...
 
bool AcceptIdContains (IContentObject content)
 Check if the given IContentObject content passes the id constraint. The id constraint is a substring match, so as long as the content's id contains the DefaultQuery.IdContainsConstraint , the id constraint passes. More...
 
bool EqualsContentQuery (ContentQuery other)
 Check if this ContentQuery would select the same content as the given ContentQuery. The equality match is based on set equality, not order equality. More...
 
override bool Equals (object obj)
 The equality operator. See EqualsContentQuery(ContentQuery) More...
 
override int GetHashCode ()
 Get the hashcode for the ContentQuery More...
 
string ToString (string existing)
 Convert the ContentQuery back into a string format. This method will guarantee that the output string would serialize back into a ContentQuery that would be equal when checked with the EqualsContentQuery method. More...
 
override string ToString ()
 Convert the ContentQuery back into a string format. This method will guarantee that the output string would serialize back into a ContentQuery that would be equal when checked with the EqualsContentQuery method. More...
 
- Public Member Functions inherited from Beamable.Common.DefaultQuery
bool AcceptIdContains (string id)
 

Static Public Member Functions

static ContentQuery Parse (string text)
 Produce a ContentQuery from its string format. The string can contain many clauses for the allowed constraints. More...
 

Public Attributes

HashSet< Type > TypeConstraints
 Type constraints instruct the ContentQuery to select content that matches the given types. In string form, this can be represented as "t:items", or "t:announcements". Multiple type constraints are treated as an OR operation. As a string, "t:items announcements" will select all items and announcements.
 
HashSet< string > TagConstraints
 Tag constraints instruct the ContentQuery to select content that contain the given tags. In string form, this can be represented as "tag:a", or "tag:a b". Multiple tag constraints are treated as an AND operation. As a string, "tag:a b" will only match content that have both the "a" tag, and the "b" tag.
 
- Public Attributes inherited from Beamable.Common.DefaultQuery
string IdContainsConstraint
 

Static Public Attributes

static readonly ContentQuery Unit = new ContentQuery()
 A ContentQuery that selects every piece of content.
 

Static Protected Member Functions

static void ApplyTypeParse (string raw, ContentQuery query)
 
static void ApplyTagParse (string raw, ContentQuery query)
 
static bool SerializeTagRule (ContentQuery query, out string str)
 
static bool SerializeTypeRule (ContentQuery query, out string str)
 
- Static Protected Member Functions inherited from Beamable.Common.DefaultQuery
static bool SerializeIdRule (DefaultQuery query, out string str)
 

Static Protected Attributes

static readonly Dictionary< string, DefaultQueryParser.ApplyParseRule< ContentQuery > > StandardRules
 
static readonly List< DefaultQueryParser.SerializeRule< ContentQuery > > StandardSerializeRules
 

Detailed Description

A ContentQuery allows you to construct a complex statement that selects specific content by type, tag, or id.

Constructor & Destructor Documentation

◆ ContentQuery()

Beamable.Common.Content.ContentQuery.ContentQuery ( ContentQuery  other)
inline

The copy-constructor for a ContentQuery

Parameters
otherA ContentQuery to clone. The given instance will not be mutated.

Member Function Documentation

◆ Accept()

virtual bool Beamable.Common.Content.ContentQuery.Accept ( IContentObject  content)
inlinevirtual

Check if the given IContentObject meets the tag, type, and id constraints. Tags are AND based, so the content must have ALL tags in the TagConstraints field. Types are OR based, so the content type only needs to be one of the types specified in the TypeConstraints field. This check allows subtypes of types in the TypeConstraints to be accepted. The id constraint is a substring match, so as long as the content's id contains the DefaultQuery.IdContainsConstraint , the id constraint passes.

Parameters
contentSome IContentObject
Returns
true if the content passes the constraints, false otherwise.

◆ AcceptIdContains()

bool Beamable.Common.Content.ContentQuery.AcceptIdContains ( IContentObject  content)
inline

Check if the given IContentObject content passes the id constraint. The id constraint is a substring match, so as long as the content's id contains the DefaultQuery.IdContainsConstraint , the id constraint passes.

Parameters
contentSome IContentObject
Returns
rue if the content passes the id constraint, false otherwise.

◆ AcceptTag()

bool Beamable.Common.Content.ContentQuery.AcceptTag ( IContentObject  content)
inline

Check if the given IContentObject meets the tag constraint. Tags are AND based, so the content must have ALL tags in the TagConstraints field.

Parameters
contentSome IContentObject
Returns
true if the content passes the tag constraint, false otherse.

◆ AcceptTags()

bool Beamable.Common.Content.ContentQuery.AcceptTags ( HashSet< string >  tags)
inline

Check if the given set of tags would meet the tag constraint. Tags are AND based, so the given set of tags must have ALL tags in the TagConstraints field.

Parameters
tagsA set of tags
Returns
true if the set of tags passes the tag constraint, false otherwise

◆ AcceptType()

bool Beamable.Common.Content.ContentQuery.AcceptType ( Type  type,
bool  allowInherit = true 
)
inline

Check if the given runtime type passes the type constraint Types are OR based, so the content type only needs to be one of the types specified in the TypeConstraints field.

Parameters
typeA runtime type that should derive from IContentObject
allowInheritBy default, a subclass of a type listed in the TypeConstraints set is allowed to pass the constraint. Disable this field to disable that behaviour, so that only exact type matches are accepted.
Returns
true if the type passes the type constraint, false otherwise.

◆ AcceptType< TContent >()

bool Beamable.Common.Content.ContentQuery.AcceptType< TContent > ( bool  allowInherit = true)
inline

Check if the given generic content type passes the type constraint. Types are OR based, so the content type only needs to be one of the types specified in the TypeConstraints field.

Parameters
allowInheritBy default, a subclass of a type listed in the TypeConstraints set is allowed to pass the constraint. Disable this field to disable that behaviour, so that only exact type matches are accepted.
Template Parameters
TContentA type of IContentObject
Returns
true if the type passes the type constraint, false otherwise.
Type Constraints
TContent :IContentObject 
TContent :new() 

◆ Equals()

override bool Beamable.Common.Content.ContentQuery.Equals ( object  obj)
inline

The equality operator. See EqualsContentQuery(ContentQuery)

Parameters
objAny object
Returns
true if the given object is a ContentQuery and yields true from EqualsContentQuery, false otherwise

◆ EqualsContentQuery()

bool Beamable.Common.Content.ContentQuery.EqualsContentQuery ( ContentQuery  other)
inline

Check if this ContentQuery would select the same content as the given ContentQuery. The equality match is based on set equality, not order equality.

Parameters
otherSome other ContentQuery
Returns
true if the two queries select the same content, false otherwise.

◆ GetHashCode()

override int Beamable.Common.Content.ContentQuery.GetHashCode ( )
inline

Get the hashcode for the ContentQuery

Returns
a hashcode

◆ Parse()

static ContentQuery Beamable.Common.Content.ContentQuery.Parse ( string  text)
inlinestatic

Produce a ContentQuery from its string format. The string can contain many clauses for the allowed constraints.

To specify type constraints, add a "t:" clause, like "t:items". You can select multiple types by specifying multiple types as space separated in the string, like "t:items announcements". The resulting types will fill out the TypeConstraints field.

To specify tag constraints, add a "tag:" clause, like "tag:a". You can select content that have many required tags by adding more tags as space separated in the string, like "t:a b". The resulting tags will fill out the TagConstraints field.

To specify an id constraint, add a "id:" clause, or specify the id as a standalone string. Both "id:items.hat" and "items.hat" produce the same output. The id will fill the DefaultQuery.IdContainsConstraint field. Ids are substring matched, so if you search for an id of "ha", it will match "items.hat".

Parameters
textThe string version of the query.
Returns
A ContentQuery

◆ ToString() [1/2]

override string Beamable.Common.Content.ContentQuery.ToString ( )
inline

Convert the ContentQuery back into a string format. This method will guarantee that the output string would serialize back into a ContentQuery that would be equal when checked with the EqualsContentQuery method.

Returns
The string form of the ContentQuery

◆ ToString() [2/2]

string Beamable.Common.Content.ContentQuery.ToString ( string  existing)
inline

Convert the ContentQuery back into a string format. This method will guarantee that the output string would serialize back into a ContentQuery that would be equal when checked with the EqualsContentQuery method.

Parameters
existingA string that used to represent the ContentQuery. The output string will try to conform to this format as close as possible to reduce string jitter.
Returns
The string form of the ContentQuery

Member Data Documentation

◆ StandardRules

readonly Dictionary<string, DefaultQueryParser.ApplyParseRule<ContentQuery> > Beamable.Common.Content.ContentQuery.StandardRules
staticprotected
Initial value:
= new Dictionary<string, DefaultQueryParser.ApplyParseRule<ContentQuery>>
{
{"t", ApplyTypeParse},
{"id", DefaultQueryParser.ApplyIdParse},
{"tag", ApplyTagParse},
}

◆ StandardSerializeRules

readonly List<DefaultQueryParser.SerializeRule<ContentQuery> > Beamable.Common.Content.ContentQuery.StandardSerializeRules
staticprotected
Initial value:
= new List<DefaultQueryParser.SerializeRule<ContentQuery>>
{
SerializeTagRule, SerializeTypeRule, SerializeIdRule
}

The documentation for this class was generated from the following file: