Class FeatureFlagsState
A snapshot of the state of all feature flags with regard to a specific user. See calling AllFlagsState(User, FlagsStateOption[]).
Inheritance
Implements
Namespace: LaunchDarkly.Sdk.Server
Assembly: LaunchDarkly.ServerSdk.dll
Syntax
public class FeatureFlagsState : Object, IJsonSerializable
Remarks
Serializing this object to JSON using System.Text.Json
or LdJsonSerialization
will produce the appropriate data structure for bootstrapping the LaunchDarkly JavaScript client.
Using Newtonsoft.Json
will not work correctly without special handling; see
LaunchDarkly.Sdk.Json for details.
Properties
Valid
True if this object contains a valid snapshot of feature flag state, or false if the state could not be computed (for instance, because the client was offline or there was no user).
Declaration
public bool Valid { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Builder(FlagsStateOption[])
Returns a builder for constructing a new instance of this class. May be useful in testing.
Declaration
public static FeatureFlagsStateBuilder Builder(params FlagsStateOption[] options)
Parameters
Type | Name | Description |
---|---|---|
FlagsStateOption[] | options | the same options that can be passed to AllFlagsState(User, FlagsStateOption[]) |
Returns
Type | Description |
---|---|
FeatureFlagsStateBuilder | a new FeatureFlagsStateBuilder |
Equals(Object)
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
System.Object | other |
Returns
Type | Description |
---|---|
System.Boolean |
GetFlagReason(String)
Returns the evaluation reason of an individual feature flag (as returned by BoolVariation(String, User, Boolean), etc.) at the time the state was recorded.
Declaration
public Nullable<EvaluationReason> GetFlagReason(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | the feature flag key |
Returns
Type | Description |
---|---|
System.Nullable<EvaluationReason> | the evaluation reason; null if reasons were not recorded, or if there was no such flag |
GetFlagValueJson(String)
Returns the value of an individual feature flag at the time the state was recorded.
Declaration
public LdValue GetFlagValueJson(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | the feature flag key |
Returns
Type | Description |
---|---|
LdValue | the flag's JSON value; Null if the flag returned the default value, or if there was no such flag |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
ToValuesJsonMap()
Returns a dictionary of flag keys to flag values.
Declaration
public IReadOnlyDictionary<string, LdValue> ToValuesJsonMap()
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<System.String, LdValue> | a dictionary of flag keys to flag values |
Remarks
If a flag would have evaluated to the default value, its value will be Null.
Do not use this method if you are passing data to the front end to "bootstrap" the
JavaScript client. Instead, serialize the FeatureFlagsState object to JSON
using JsonConvert.SerializeObject()
.