internal FeatureFlagBuilder(FeatureFlag from) { _key = from.Key; _version = from.Version; _on = from.On; _prerequisites = new List <Prerequisite>(from.Prerequisites); _salt = from.Salt; _targets = new List <Target>(from.Targets); _rules = new List <FlagRule>(from.Rules); _fallthrough = from.Fallthrough; _offVariation = from.OffVariation; _variations = new List <LdValue>(from.Variations); _trackEvents = from.TrackEvents; _trackEventsFallthrough = from.TrackEventsFallthrough; _debugEventsUntilDate = from.DebugEventsUntilDate; _deleted = from.Deleted; _clientSide = from.ClientSide; }
internal FeatureFlag(string key, int version, bool deleted, bool on, IEnumerable <Prerequisite> prerequisites, IEnumerable <Target> targets, IEnumerable <FlagRule> rules, VariationOrRollout fallthrough, int?offVariation, IEnumerable <LdValue> variations, string salt, bool trackEvents, bool trackEventsFallthrough, UnixMillisecondTime?debugEventsUntilDate, bool clientSide) { Key = key; Version = version; Deleted = deleted; On = on; Prerequisites = prerequisites ?? Enumerable.Empty <Prerequisite>(); Targets = targets ?? Enumerable.Empty <Target>(); Rules = rules ?? Enumerable.Empty <FlagRule>(); Fallthrough = fallthrough; OffVariation = offVariation; Variations = variations ?? Enumerable.Empty <LdValue>(); Salt = salt; TrackEvents = trackEvents; TrackEventsFallthrough = trackEventsFallthrough; DebugEventsUntilDate = debugEventsUntilDate; ClientSide = clientSide; }
public object ReadJson(ref JReader reader) { string key = null; int version = 0; bool deleted = false; bool on = false; ImmutableList <Prerequisite> prerequisites = null; ImmutableList <Target> targets = null; ImmutableList <FlagRule> rules = null; string salt = null; VariationOrRollout fallthrough = new VariationOrRollout(); int?offVariation = null; ImmutableList <LdValue> variations = null; bool trackEvents = false, trackEventsFallthrough = false; UnixMillisecondTime?debugEventsUntilDate = null; bool clientSide = false; for (var obj = reader.Object().WithRequiredProperties(_requiredProperties); obj.Next(ref reader);) { switch (obj.Name) { case var n when n == "key": key = reader.String(); break; case var n when n == "version": version = reader.Int(); break; case var n when n == "deleted": deleted = reader.Bool(); break; case var n when n == "on": on = reader.Bool(); break; case var n when n == "prerequisites": var prereqsBuilder = ImmutableList.CreateBuilder <Prerequisite>(); for (var arr = reader.ArrayOrNull(); arr.Next(ref reader);) { prereqsBuilder.Add(ReadPrerequisite(ref reader)); } prerequisites = prereqsBuilder.ToImmutable(); break; case var n when n == "targets": var targetsBuilder = ImmutableList.CreateBuilder <Target>(); for (var arr = reader.ArrayOrNull(); arr.Next(ref reader);) { targetsBuilder.Add(ReadTarget(ref reader)); } targets = targetsBuilder.ToImmutable(); break; case var n when n == "rules": var rulesBuilder = ImmutableList.CreateBuilder <FlagRule>(); for (var arr = reader.ArrayOrNull(); arr.Next(ref reader);) { rulesBuilder.Add(ReadFlagRule(ref reader)); } rules = rulesBuilder.ToImmutable(); break; case var n when n == "fallthrough": fallthrough = ReadVariationOrRollout(ref reader); break; case var n when n == "offVariation": offVariation = reader.IntOrNull(); break; case var n when n == "variations": variations = SerializationHelpers.ReadValues(ref reader); break; case var n when n == "salt": salt = reader.StringOrNull(); break; case var n when n == "trackEvents": trackEvents = reader.Bool(); break; case var n when n == "trackEventsFallthrough": trackEventsFallthrough = reader.Bool(); break; case var n when n == "debugEventsUntilDate": var dt = reader.LongOrNull(); debugEventsUntilDate = dt.HasValue ? UnixMillisecondTime.OfMillis(dt.Value) : (UnixMillisecondTime?)null; break; case var n when n == "clientSide": clientSide = reader.Bool(); break; } } if (key is null && !deleted) { throw new RequiredPropertyException("key", 0); } return(new FeatureFlag(key, version, deleted, on, prerequisites, targets, rules, fallthrough, offVariation, variations, salt, trackEvents, trackEventsFallthrough, debugEventsUntilDate, clientSide)); }
internal FeatureFlagBuilder FallthroughVariation(int variation) { _fallthrough = new VariationOrRollout(variation, null); return(this); }
internal FeatureFlagBuilder Fallthrough(VariationOrRollout fallthrough) { _fallthrough = fallthrough; return(this); }