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)); }
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); } }
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)); }
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)); }
public object GetAnnotation <T>(AnnotationDef annotationDef, T skylineObject, Annotations annotations) where T : SkylineObject { return(GetAnnotation(annotationDef, typeof(T), skylineObject, annotations)); }