Example #1
0
        public object ConvertAnnotationValue(AnnotationDef annotationDef, object value)
        {
            if (value == null || value is string)
            {
                return(annotationDef.ParsePersistedString((string)value));
            }

            if (annotationDef.Type == AnnotationDef.AnnotationType.number)
            {
                if (value is double doubleValue)
                {
                    return(doubleValue);
                }

                if (value is float floatValue)
                {
                    return((double)floatValue);
                }

                if (value is int intValue)
                {
                    return((double)intValue);
                }
            }

            string strValue = LocalizationHelper.CallWithCulture(CultureInfo.InvariantCulture, value.ToString);

            return(annotationDef.ParsePersistedString(strValue));
        }
Example #2
0
        public object GetAnnotation(AnnotationDef annotationDef, Type skylineObjectType,
                                    SkylineObject skylineObject, Annotations annotations)
        {
            var expression = annotationDef.Expression;

            if (expression == null)
            {
                return(annotations.GetAnnotation(annotationDef));
            }

            ColumnSelector columnSelector = GetColumnSelector(skylineObjectType, expression.Column);

            if (!columnSelector.IsValid)
            {
                return(NAME_ERROR);
            }

            try
            {
                if (expression.AggregateOperation == null)
                {
                    return(ConvertAnnotationValue(annotationDef, columnSelector.GetSingleValue(skylineObject)));
                }

                return(ConvertAnnotationValue(annotationDef, columnSelector.AggregateValues(expression.AggregateOperation, skylineObject)));
            }
            catch (Exception)
            {
                return(ERROR_VALUE);
            }
        }
Example #3
0
 public bool Equals(AnnotationDef other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(base.Equals(other) && Equals(other.AnnotationTargets, AnnotationTargets) &&
            other.Type == Type && ArrayUtil.EqualsDeep(other.Items, Items) && Equals(other.Lookup, Lookup));
 }
Example #4
0
        public object GetReplicateAnnotation(AnnotationDef annotationDef, ChromatogramSet chromatogramSet)
        {
            if (annotationDef.Expression == null)
            {
                return(chromatogramSet.Annotations.GetAnnotation(annotationDef));
            }

            if (!SrmDocument.Settings.HasResults)
            {
                return(null);
            }

            int replicateIndex;

            if (!SrmDocument.Settings.MeasuredResults.TryGetChromatogramSet(chromatogramSet.Name, out _,
                                                                            out replicateIndex))
            {
                return(null);
            }

            return(GetAnnotation(annotationDef, new Replicate(SkylineDataSchema, replicateIndex),
                                 chromatogramSet.Annotations));
        }
Example #5
0
 public object GetAnnotation <T>(AnnotationDef annotationDef, T skylineObject,
                                 Annotations annotations) where T : SkylineObject
 {
     return(GetAnnotation(annotationDef, typeof(T), skylineObject, annotations));
 }