예제 #1
0
        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));
        }
예제 #2
0
 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);
 }
예제 #3
0
            public Annotations UpdateAnnotations(Annotations annotations, SkylineObject skylineObject)
            {
                foreach (var annotationDef in AnnotationDefs)
                {
                    annotations =
                        annotations.ChangeAnnotation(annotationDef, skylineObject.GetAnnotation(annotationDef));
                }

                return(annotations);
            }