private static Annotations SetAnnotationValue(CultureInfo cultureInfo, Annotations annotations, AnnotationDef annotationDef, string value) { if (string.IsNullOrEmpty(value)) { return(annotations.RemoveAnnotation(annotationDef.Name)); } string persistedValue; switch (annotationDef.Type) { case AnnotationDef.AnnotationType.number: persistedValue = annotationDef.ToPersistedString(double.Parse(value, cultureInfo)); break; case AnnotationDef.AnnotationType.true_false: if (false.ToString(cultureInfo) == value) { return(annotations.RemoveAnnotation(annotationDef.Name)); } persistedValue = annotationDef.ToPersistedString(true); break; default: persistedValue = value; break; } return(annotations.ChangeAnnotation(annotationDef.Name, persistedValue)); }
private Annotations AddAnnotations(Annotations annotations, AnnotationDef.AnnotationTarget annotationTarget) { annotations = annotations.ChangeAnnotation("Text", annotationTarget + ":" + _counter++); if (DocumentAnnotations.NOTE_TARGETS.Contains(annotationTarget)) { annotations = annotations.ChangeNote("Note" + _counter++); } annotations = annotations.ChangeAnnotation("Number", (_counter++ *.1).ToString(CultureInfo.InvariantCulture)); if (0 != (_elementCount & 2)) { _counter++; annotations = annotations.ChangeAnnotation("TrueFalse", "TrueFalse"); } annotations = annotations.ChangeAnnotation(GetAnnotationTargetName(annotationTarget), annotationTarget + ":" + _counter++); return(annotations); }
public Annotations UpdateAnnotations(Annotations annotations, SkylineObject skylineObject) { foreach (var annotationDef in AnnotationDefs) { annotations = annotations.ChangeAnnotation(annotationDef, skylineObject.GetAnnotation(annotationDef)); } return(annotations); }