Struct ContextKind
A string value provided by the application to describe what kind of entity a Context represents.
Implements
Inherited Members
Namespace: LaunchDarkly.Sdk
Assembly: LaunchDarkly.CommonSdk.dll
Syntax
public readonly struct ContextKind : IEquatable<ContextKind>
Remarks
The type is a simple wrapper for a string. Using a type that is not just string
makes it clearer where a context kind is expected or returned in the SDK API, so it
cannot be confused with other important strings such as Key. To
convert a literal string to this type, you can use the shortcut Of(string).
The meaning of the context kind is completely up to the application. Validation rules are as follows:
- It may only contain letters, numbers, and the characters ".", "_", and "-".
- It cannot equal the literal string "kind".
- For a single-kind context, it cannot equal "multi".
If no kind is specified, the default is "user" (the constant Default).
However, an uninitialized struct (new ContextKind()
is invalid and has a string
value of "".
For a multi-kind Context (see NewMulti(params Context[])), the kind of the top-level Context is always "multi" (the constant Multi); there is a specific Kind for each of the Contexts contained within it.
To learn more, read the documentation.
Constructors
ContextKind(string)
Constructor from a string value.
Declaration
public ContextKind(string stringValue)
Parameters
Type | Name | Description |
---|---|---|
string | stringValue | the string value |
Remarks
A value of null or "" will be changed to Default.
Fields
Default
A constant for the default kind of "user".
Declaration
public static readonly ContextKind Default
Field Value
Type | Description |
---|---|
ContextKind |
Multi
A constant for the kind that all multi-kind Contexts have.
Declaration
public static readonly ContextKind Multi
Field Value
Type | Description |
---|---|
ContextKind |
Properties
IsDefault
True if this is equal to Default ("user").
Declaration
public bool IsDefault { get; }
Property Value
Type | Description |
---|---|
bool |
Value
The string value of the context kind. This is never null.
Declaration
public string Value { get; }
Property Value
Type | Description |
---|---|
string |
Methods
Equals(ContextKind)
Declaration
public bool Equals(ContextKind other)
Parameters
Type | Name | Description |
---|---|---|
ContextKind | other |
Returns
Type | Description |
---|---|
bool |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
Of(string)
Shortcut for calling the constructor.
Declaration
public static ContextKind Of(string stringValue)
Parameters
Type | Name | Description |
---|---|---|
string | stringValue | the string value |
Returns
Type | Description |
---|---|
ContextKind | a ContextKind wrapping this value |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
Operators
operator ==(ContextKind, ContextKind)
Declaration
public static bool operator ==(ContextKind a, ContextKind b)
Parameters
Type | Name | Description |
---|---|---|
ContextKind | a | |
ContextKind | b |
Returns
Type | Description |
---|---|
bool |
operator !=(ContextKind, ContextKind)
Declaration
public static bool operator !=(ContextKind a, ContextKind b)
Parameters
Type | Name | Description |
---|---|---|
ContextKind | a | |
ContextKind | b |
Returns
Type | Description |
---|---|
bool |