コード例 #1
0
        /// <summary>
        /// The UpdateAggregation.
        /// </summary>
        /// <returns>The <see cref="MemberRubrics"/>.</returns>
        public MemberRubrics UpdateAggregation()
        {
            AggregateOperand parsed      = new AggregateOperand();
            Links            targetLinks = figures.Linker.TargetLinks;

            aggregateRubrics = new MemberRubrics();
            MemberRubric[] _aggregateRubrics = figures.Rubrics.AsValues()
                                               .Where(c => (c.RubricName.Split('#').Length > 1) ||
                                                      (c.AggregateRubric != null &&
                                                       c.AggregateOperand != AggregateOperand.None) ||
                                                      c.AggregateOperand != AggregateOperand.None).ToArray();
            foreach (MemberRubric c in _aggregateRubrics)
            {
                c.AggregateRubric = (c.AggregateRubric != null) ?
                                    c.AggregateRubric :
                                    (c.AggregateOperand != AggregateOperand.None) ?
                                    new MemberRubric(c)
                {
                    RubricName = c.RubricName
                } :
                new MemberRubric(c)
                {
                    RubricName = c.RubricName.Split('#')[1]
                };

                c.AggregateOperand = c.AggregateOperand != AggregateOperand.None ?
                                     c.AggregateOperand :
                                     (Enum.TryParse(c.RubricName.Split('#')[0], true, out parsed)) ?
                                     parsed : AggregateOperand.None;

                c.AggregateLinkId = (targetLinks.AsValues().Where(cr => cr.Target.Figures.Rubrics.AsValues()
                                                                  .Where(ct => ct.RubricName == ((c.AggregateRubric != null) ?
                                                                                                 c.AggregateRubric.RubricName :
                                                                                                 c.RubricName.Split('#')[1])).Any()).Any()) ?
                                    targetLinks.AsValues().Where(cr => cr.Target.Figures.Rubrics.AsValues()
                                                                 .Where(ct => ct.RubricName == ((c.AggregateRubric != null) ?
                                                                                                c.AggregateRubric.RubricName :
                                                                                                c.RubricName.Split('#')[1])).Any()).ToArray()
                                    .Select(ix => targetLinks.IndexOf(ix)).FirstOrDefault()
                                              : -1;

                c.AggregateOrdinal = targetLinks.AsValues().Where(cr => cr.Target.Figures.Rubrics.AsValues()
                                                                  .Where(ct => ct.RubricName == ((c.AggregateRubric != null) ?
                                                                                                 c.AggregateRubric.RubricName :
                                                                                                 c.RubricName.Split('#')[1])).Any())
                                     .Select(cr => cr.Target.Figures.Rubrics.AsValues()
                                             .Where(ct => ct.RubricName == ((c.AggregateRubric != null) ?
                                                                            c.AggregateRubric.RubricName :
                                                                            c.RubricName.Split('#')[1]))
                                             .Select(o => o.RubricId).FirstOrDefault()).FirstOrDefault();
            }

            aggregateRubrics.Put(_aggregateRubrics);
            aggregateRubrics.AsValues().Where(j => j.AggregateLinkId > -1)
            .Select(p => p.AggregateLinks =
                        new Links(targetLinks.AsCards().Where((x, y) =>
                                                              p.AggregateLinkId == x.Index).Select(v => v.Value).ToArray()));

            UpdateReplication();

            return(aggregateRubrics);
        }