public void SetFirstSeenOn([NotNull] IMitigation mitigation, Iteration info) { var iterationFirstSeenPropertyType = GetIterationFirstSeenPropertyType(); var mitigationExposurePropertyType = GetMitigationExposurePropertyType(); if (iterationFirstSeenPropertyType != null && mitigationExposurePropertyType != null) { var propertyFirstSeen = mitigation.GetProperty(iterationFirstSeenPropertyType) ?? mitigation.AddProperty(iterationFirstSeenPropertyType, null); var propertyMitigationExposure = mitigation.GetProperty(mitigationExposurePropertyType) ?? mitigation.AddProperty(mitigationExposurePropertyType, null); if (propertyFirstSeen is IPropertyJsonSerializableObject firstSeen && propertyMitigationExposure is IPropertySingleLineString mitigationExposure) { if (info == null) { firstSeen.StringValue = null; mitigationExposure.StringValue = null; } else { firstSeen.Value = new IterationInfo(info); mitigationExposure.StringValue = GetMitigationExposure(mitigation); } } } }
public void SetReview([NotNull] IMitigation mitigation, [NotNull] ReviewInfo info) { ReviewInfo result = null; var propertyType = GetReviewPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType) ?? mitigation.AddProperty(propertyType, null); if (property is IPropertyJsonSerializableObject jsonSerializableObject) { jsonSerializableObject.Value = info; } } }
public bool HasChanged([NotNull] IMitigation mitigation) { var result = false; var mitigationExposurePropertyType = GetMitigationExposurePropertyType(); if (mitigationExposurePropertyType != null) { var propertyMitigationExposure = mitigation.GetProperty(mitigationExposurePropertyType); if (propertyMitigationExposure is IPropertySingleLineString mitigationExposure) { result = string.CompareOrdinal(mitigationExposure.StringValue, GetMitigationExposure(mitigation)) != 0; } } return(result); }
public IterationInfo GetFirstSeenOn([NotNull] IMitigation mitigation) { IterationInfo result = null; var propertyType = GetIterationFirstSeenPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is IterationInfo iterationInfo && iterationInfo.IsValid) { result = iterationInfo; } } return(result); }
public ReviewInfo GetReview([NotNull] IMitigation mitigation) { ReviewInfo result = null; var propertyType = GetReviewPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType) ?? mitigation.AddProperty(propertyType, null); if (property is IPropertyJsonSerializableObject jsonSerializableObject && jsonSerializableObject.Value is ReviewInfo reviewInfo) { result = reviewInfo; } } return(result); }
private RoadmapStatus GetStatusFromProperties(IMitigation mitigation) { RoadmapStatus result = RoadmapStatus.NotAssessed; var propertyType = GetPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property != null && Enum.TryParse <RoadmapStatus>(property.StringValue, out var status)) { result = status; } } return(result); }
public static void SetStatus(this IMitigation mitigation, RoadmapStatus status) { var model = mitigation?.Model; if (model != null) { var schemaManager = new RoadmapPropertySchemaManager(model); var propertyType = schemaManager.GetPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property == null) { mitigation.AddProperty(propertyType, status.ToString()); } else { property.StringValue = status.ToString(); } } } }
private static RoadmapStatus GetStatusFromProperties(IMitigation mitigation) { RoadmapStatus result = RoadmapStatus.NotAssessed; var model = mitigation?.Model; if (model != null) { var schemaManager = new RoadmapPropertySchemaManager(model); var propertyType = schemaManager.GetPropertyType(); if (propertyType != null) { var property = mitigation.GetProperty(propertyType); if (property != null && Enum.TryParse <RoadmapStatus>(property.StringValue, out var status)) { result = status; } } } return(result); }