-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathFeatureStateModel.cs
More file actions
34 lines (32 loc) · 1.37 KB
/
FeatureStateModel.cs
File metadata and controls
34 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using FlagsmithEngine.Exceptions;
namespace FlagsmithEngine.Feature.Models
{
public class FeatureStateModel
{
[JsonProperty(PropertyName = "feature")]
public FeatureModel Feature { get; set; }
[JsonProperty(PropertyName = "enabled")]
public bool Enabled { get; set; }
[JsonProperty("feature_state_value")]
public object Value { get; set; }
[JsonProperty(PropertyName = "multivariate_feature_state_values")]
public List<MultivariateFeatureStateValueModel> MultivariateFeatureStateValues { get; set; }
[JsonProperty(PropertyName = "django_id")]
public int? DjangoId { get; set; }
[JsonProperty(PropertyName = "featurestate_uuid")]
public string FeatureStateUUID { get; set; }
[JsonProperty(PropertyName = "feature_segment")]
public FeatureSegmentModel FeatureSegment { get; set; } = null;
[OnSerialized()]
private void ValidatePercentageAllocations(StreamingContext _)
{
var totalAllocation = MultivariateFeatureStateValues?.Sum(m => m.PercentageAllocation);
if (totalAllocation > 100)
throw new InvalidPercentageAllocation("Total percentage allocation should not be more than 100");
}
}
}