Example #1
0
        public override PropertyDescriptor GetPropertyDescriptor(Type type, string name)
        {
            var propertyDescriptor = base.GetPropertyDescriptor(type, name);

            if (null != propertyDescriptor)
            {
                return(propertyDescriptor);
            }
            if (null == type)
            {
                return(null);
            }
            propertyDescriptor = RatioPropertyDescriptor.GetProperty(Document, type, name);
            if (null != propertyDescriptor)
            {
                return(propertyDescriptor);
            }
            if (name.StartsWith(AnnotationDef.ANNOTATION_PREFIX))
            {
                var annotationTargets = GetAnnotationTargets(type);
                if (!annotationTargets.IsEmpty)
                {
                    var annotationDef = new AnnotationDef(name.Substring(AnnotationDef.ANNOTATION_PREFIX.Length),
                                                          annotationTargets, AnnotationDef.AnnotationType.text, new string[0]);
                    return(new AnnotationPropertyDescriptor(this, annotationDef, false));
                }
            }

            return(null);
        }
Example #2
0
        private ColumnSpec ConvertReportColumn(ReportColumn reportColumn)
        {
            var    identifierPath            = PropertyPath.Root;
            var    databindingTableAttribute = GetDatabindingTableAttribute(reportColumn);
            var    component  = reportColumn.Table;
            string oldCaption = null;

            foreach (string part in reportColumn.Column.Parts)
            {
                PropertyPath propertyPath;
                if (part.StartsWith(AnnotationDef.ANNOTATION_PREFIX))
                {
                    string annotationName = AnnotationDef.GetColumnDisplayName(part);
                    if (component == typeof(DbProteinResult))
                    {
                        propertyPath = PropertyPath.Root.Property(@"Replicate").Property(AnnotationDef.ANNOTATION_PREFIX + annotationName);
                    }
                    else
                    {
                        propertyPath = PropertyPath.Root.Property(AnnotationDef.ANNOTATION_PREFIX + annotationName);
                    }
                    oldCaption = annotationName;
                    component  = typeof(string);
                }
                else if (RatioPropertyAccessor.IsRatioOrRdotpProperty(part))
                {
                    propertyPath = null;
                    if (component == typeof(DbPeptideResult))
                    {
                        const string prefixPeptideRatio = "ratio_Ratio";
                        string       labelName, standardName;
                        if (part.StartsWith(prefixPeptideRatio))
                        {
                            if (TryParseLabelNames(part.Substring(prefixPeptideRatio.Length), out labelName, out standardName))
                            {
                                propertyPath = PropertyPath.Root.Property(RatioPropertyDescriptor.MakePropertyName(
                                                                              RatioPropertyDescriptor.RATIO_PREFIX, labelName, standardName));
                            }
                        }
                        const string prefixPeptideRdotp = "rdotp_DotProduct";
                        if (part.StartsWith(prefixPeptideRdotp))
                        {
                            if (TryParseLabelNames(part.Substring(prefixPeptideRdotp.Length), out labelName, out standardName))
                            {
                                propertyPath = PropertyPath.Root.Property(RatioPropertyDescriptor.MakePropertyName(
                                                                              RatioPropertyDescriptor.RDOTP_PREFIX, labelName, standardName));
                            }
                        }
                    }
                    else if (component == typeof(DbPrecursorResult))
                    {
                        const string prefixPrecursorRatio = "ratio_TotalAreaRatioTo";
                        const string prefixPrecursorRdotp = "rdotp_DotProductTo";
                        if (part.StartsWith(prefixPrecursorRatio))
                        {
                            propertyPath = PropertyPath.Root.Property(
                                RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RATIO_PREFIX, part.Substring(prefixPrecursorRatio.Length)));
                        }
                        else if (part.StartsWith(prefixPrecursorRdotp))
                        {
                            propertyPath = PropertyPath.Root.Property(
                                RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RDOTP_PREFIX,
                                                                         part.Substring(prefixPrecursorRdotp.Length)));
                        }
                    }
                    else if (component == typeof(DbTransitionResult))
                    {
                        const string prefixTransitionRatio = "ratio_AreaRatioTo";
                        if (part.StartsWith(prefixTransitionRatio))
                        {
                            propertyPath = PropertyPath.Root.Property(
                                RatioPropertyDescriptor.MakePropertyName(RatioPropertyDescriptor.RATIO_PREFIX,
                                                                         part.Substring(prefixTransitionRatio.Length)));
                        }
                    }
                    component  = typeof(double);
                    oldCaption = null;
                    if (null == propertyPath)
                    {
                        Trace.TraceWarning(@"Unable to parse ratio property {0}", part);
                        propertyPath = PropertyPath.Root.Property(part);
                    }
                }
//                else if (component == typeof (DbProteinResult) && part == "ResultFile")
//                {
//                    propertyPath = PropertyPath.Parse("Results!*.Value");
//                }
                else
                {
                    PropertyInfo property = component.GetProperty(part);
                    if (null == property)
                    {
                        Trace.TraceWarning(@"Could not find property {0}", part);
                        continue;
                    }
                    propertyPath = PropertyPath.Root.Property(part);
                    foreach (DatabindingColumnAttribute databindingColumn in
                             property.GetCustomAttributes(typeof(DatabindingColumnAttribute), true))
                    {
                        if (null != databindingColumn.Name)
                        {
                            propertyPath = PropertyPath.Parse(databindingColumn.Name);
                            break;
                        }
                    }
                    oldCaption = property.Name;
                    foreach (QueryColumn attr in property.GetCustomAttributes(typeof(QueryColumn), true))
                    {
                        oldCaption = attr.FullName ?? oldCaption;
                    }
                    component = property.PropertyType;
                }
                identifierPath = identifierPath.Concat(propertyPath);
            }
            var columnDescriptor = GetColumnDescriptor(databindingTableAttribute, identifierPath);

            if (null == columnDescriptor)
            {
                return(new ColumnSpec(identifierPath));
            }
            var columnSpec = new ColumnSpec(columnDescriptor.PropertyPath);
            var newCaption = DataSchema.GetColumnCaption(columnDescriptor).GetCaption(DataSchemaLocalizer.INVARIANT);

            if (oldCaption != newCaption)
            {
                columnSpec = columnSpec.SetCaption(oldCaption);
            }
            return(columnSpec);
        }
Example #3
0
 protected bool Equals(RatioPropertyDescriptor other)
 {
     return(base.Equals(other) &&
            _componentType == other._componentType &&
            _getterFunc.Equals(other._getterFunc));
 }
Example #4
0
 public IEnumerable <RatioPropertyDescriptor> GetRatioProperties(Type type)
 {
     return(RatioPropertyDescriptor.ListProperties(Document, type));
 }