Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
 public Annotations ChangeAnnotation(AnnotationDef annotationDef, object value)
 {
     return(ChangeAnnotation(annotationDef.Name, annotationDef.ToPersistedString(value)));
 }