public CalculatedSeverityConfiguration GetSeverityCalculationConfig([NotNull] IThreatEvent threatEvent) { CalculatedSeverityConfiguration result = null; var propertyType = GetCalculatedSeverityPropertyType(); if (propertyType != null) { var property = threatEvent.GetProperty(propertyType); if (property is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is CalculatedSeverityConfiguration configuration) { result = configuration; } } return(result); }
public CalculatedSeverityConfiguration SetSeverityCalculationConfig([NotNull] IThreatEvent threatEvent, int points, [Required] string reason) { CalculatedSeverityConfiguration result = null; var propertyType = GetCalculatedSeverityPropertyType(); if (propertyType != null) { var property = threatEvent.GetProperty(propertyType); if (property is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is CalculatedSeverityConfiguration configuration) { result = configuration; } else { result = new CalculatedSeverityConfiguration(); if (property == null) { property = threatEvent.AddProperty(propertyType, null); if (property is IPropertyJsonSerializableObject jsonObject) { jsonObject.Value = result; } } else if (property is IPropertyJsonSerializableObject jsonObject) { jsonObject.Value = result; } } result.Delta = points; result.DeltaReason = reason; result.DeltaSetBy = UserName.GetDisplayName(); result.DeltaSetOn = DateTime.Now; }