Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataCollectorNode{T}"/> class.
 /// </summary>
 /// <param name="categoryDecompositionHierarchy">
 /// The <see cref="CategoryDecompositionHierarchy"/> associated with this node's subtree.
 /// </param>
 /// <param name="topElement">
 /// The <see cref="CDP4Common.EngineeringModelData.NestedElement"/> associated with this node.
 /// </param>
 /// <param name="parent">
 /// The parent node in the hierarhical tree upon which the data collector is based.
 /// </param>
 public DataCollectorNode(
     CategoryDecompositionHierarchy categoryDecompositionHierarchy,
     NestedElement topElement,
     DataCollectorNode <T> parent = null)
 {
     this.Initialize();
     this.NestedElement = topElement;
     this.parent        = parent;
     this.InitializeCategoryDecompositionHierarchy(categoryDecompositionHierarchy);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the tree of <see cref="DataCollectorNode{T}"/>s. This method can call itself recursively.
        /// </summary>
        /// <param name="nestedElement">
        /// The <see cref="NestedElement"/>
        /// </param>
        /// <param name="categoryDecompositionHierarchy">
        /// The <see cref="CategoryDecompositionHierarchy"/> used for filtering the considered <see cref="NestedElement"/> items.
        /// </param>
        /// <param name="nestedElements">
        /// The <see cref="List{NestedElement}"/>s
        /// </param>
        /// <param name="parentNode">
        /// The <see cref=" DataCollectorNode{T}"/> that is the parent of new nodes.
        /// </param>
        /// <returns>
        /// An <see cref="IEnumerable{T}"/> of <see cref="DataCollectorNode{T}"/>
        /// </returns>
        private IEnumerable <DataCollectorNode <T> > GetDataCollectorNodes(NestedElement nestedElement, CategoryDecompositionHierarchy categoryDecompositionHierarchy, List <NestedElement> nestedElements, DataCollectorNode <T> parentNode)
        {
            var resultNodes = new List <DataCollectorNode <T> >();
            DataCollectorNode <T> newNode = null;
            var searchCategory            = categoryDecompositionHierarchy;

            if (categoryDecompositionHierarchy.Child != null && parentNode?.CountCategoryRecursionLevel(categoryDecompositionHierarchy.Category) > 0 && nestedElement.IsMemberOfCategory(categoryDecompositionHierarchy.Child.Category))
            {
                searchCategory = categoryDecompositionHierarchy.Child;

                newNode = new DataCollectorNode <T>(searchCategory, nestedElement, parentNode);
                parentNode.Children.Add(newNode);
                resultNodes.Add(newNode);
            }
            else if (nestedElement.IsMemberOfCategory(categoryDecompositionHierarchy.Category))
            {
                newNode = new DataCollectorNode <T>(categoryDecompositionHierarchy, nestedElement, parentNode);
                parentNode?.Children.Add(newNode);
                resultNodes.Add(newNode);
            }
            else if (!(categoryDecompositionHierarchy.Child?.AllowSkipUnknownCategories ?? true))
            {
                return(resultNodes);
            }

            var children = nestedElement.GetChildren(nestedElements).ToList();

            foreach (var child in children)
            {
                var nodes = this.GetDataCollectorNodes(child, searchCategory, nestedElements, newNode ?? parentNode).ToArray();

                if (newNode == null && nodes.Any())
                {
                    resultNodes = resultNodes.Concat(nodes).ToList();
                }
            }

            return(resultNodes);
        }
        /// <summary>
        /// Initializes a reported category column based on the corresponding <see cref="ElementBase"/>
        /// within the associated <see cref="DataCollectorNode{T}"/>.
        /// </summary>
        /// <param name="node">
        /// The associated <see cref="DataCollectorNode{T}"/>.
        /// </param>
        /// <param name="propertyInfo">
        /// The <see cref="PropertyInfo"/> object for this <see cref="DataCollectorCategory{T}"/>'s usage in a class.
        /// </param>
        internal override void Initialize(DataCollectorNode <T> node, PropertyInfo propertyInfo)
        {
            var definedShortNameAttribute = GetParameterAttribute(propertyInfo);

            this.FieldName = definedShortNameAttribute?.FieldName;
            this.ShortName = definedShortNameAttribute?.ShortName;
            this.Node      = node;
            this.Value     = this.IsMemberOfCategory();

            this.MainCategory = this.CategoriesInRequiredRdl.FirstOrDefault(x => x.ShortName == this.ShortName);

            if (this.Value)
            {
                var childCategories = this.CategoriesInRequiredRdl.Where(x => x.AllSuperCategories().Contains(this.MainCategory));

                this.ActualCategory =
                    this.Node.FindNestedElementCategories(childCategories)
                    .FirstOrDefault()
                    ??
                    this.MainCategory;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a reported column based on the corresponding <see cref="DataCollectorNode{T}"/>
 /// associated with the current <see cref="DataCollectorRow"/>.
 /// </summary>
 /// <param name="node">
 /// The associated <see cref="DataCollectorNode{T}"/>.
 /// </param>
 /// <param name="propertyInfo">
 /// The <see cref="PropertyInfo"/> object for this <see cref="DataCollectorCategory{T}"/>'s usage in a class.
 /// </param>
 internal abstract void Initialize(DataCollectorNode <T> node, PropertyInfo propertyInfo);