Beispiel #1
0
        /// <summary>
        /// Gets the names of the top-level nodes in the projection state tree (for non-polymorphic scenarios) that match a set of attribute names
        /// </summary>
        /// <param name="projCtx">The projection context.</param>
        /// <param name="attrNames">The list of attribute names to match from.</param>
        internal static Dictionary <string, string> GetTopList(ProjectionContext projCtx, List <string> attrNames)
        {
            // This dictionary contains a mapping from the top-level (most recent) name of an attribute
            // to the attribute name the top-level name was derived from (the name contained in the given list)
            Dictionary <string, string> topLevelAttributeNames = new Dictionary <string, string>();

            // Iterate through each attribute name in the list and search for their top-level names
            foreach (string attrName in attrNames)
            {
                // Iterate through each projection attribute state in the current set and check if its
                // current resolved attribute's name is the top-level name of the current attrName
                foreach (ProjectionAttributeState top in projCtx.CurrentAttributeStateSet.States)
                {
                    SearchStructure st = new SearchStructure();
                    st = SearchStructure.BuildStructure(top, top, attrName, st, false, 0);
                    // Found the top-level name
                    if (st?.Result.FoundFlag == true)
                    {
                        // Create a mapping from the top-level name of the attribute to the name it has in the given list
                        topLevelAttributeNames[top.CurrentResolvedAttribute.ResolvedName] = attrName;
                    }
                }
            }
            return(topLevelAttributeNames);
        }
Beispiel #2
0
        /// <summary>
        /// Build a structure using a stack
        /// </summary>
        /// <param name="curr"></param>
        /// <param name="top"></param>
        /// <param name="attrName"></param>
        /// <param name="st"></param>
        /// <param name="foundFlag"></param>
        /// <returns></returns>
        internal static SearchStructure BuildStructure(
            ProjectionAttributeState curr,
            ProjectionAttributeState top,
            string attrName,
            SearchStructure st,
            bool foundFlag,
            int foundDepth)
        {
            if (curr != null)
            {
                st.Add(curr);

                if (StringUtils.EqualsWithCase(curr.CurrentResolvedAttribute.ResolvedName, attrName))
                {
                    foundFlag            = true;
                    st.Result.FoundFlag  = true;
                    st.Result.FoundDepth = foundDepth;
                    st.Result.Found      = curr;
                }
                if (foundFlag && (curr?.PreviousStateList == null || curr?.PreviousStateList?.Count == 0))
                {
                    st.Result.Leaf.Add(curr);
                }

                if (curr.PreviousStateList?.Count > 0)
                {
                    foreach (var prev in curr.PreviousStateList)
                    {
                        BuildStructure(prev, top, attrName, st, foundFlag, foundDepth + 1);
                    }
                }
            }

            return(st);
        }
        /// <summary>
        /// Get top node of the projection state tree for non-polymorphic scenarios
        /// </summary>
        /// <param name="projCtx"></param>
        /// <param name="attrName"></param>
        /// <returns></returns>
        internal static List <ProjectionAttributeState> GetTop(ProjectionContext projCtx, string attrName)
        {
            SearchResult result = new SearchResult();

            foreach (ProjectionAttributeState top in projCtx.CurrentAttributeStateSet.Values)
            {
                SearchStructure st = new SearchStructure();
                st = SearchStructure.BuildStructure(top, top, attrName, st, false, 0);
                if (st?.Result.FoundFlag == true)
                {
                    result = st.Result;
                }
            }
            return(result?.Top);
        }
Beispiel #4
0
        /// <summary>
        /// Get leaf nodes of the projection state tree for polymorphic scenarios
        /// </summary>
        /// <param name="projCtx"></param>
        /// <param name="attrName"></param>
        /// <returns></returns>
        internal static List <ProjectionAttributeState> GetLeafList(ProjectionContext projCtx, string attrName)
        {
            SearchResult result = null;

            foreach (ProjectionAttributeState top in projCtx.CurrentAttributeStateSet.States)
            {
                SearchStructure st = new SearchStructure();
                st = SearchStructure.BuildStructure(top, top, attrName, st, false, 0);
                if (st?.Result.FoundFlag == true && st.Result.Leaf.Count > 0)
                {
                    result = st.Result;
                }
            }
            return(result?.Leaf);
        }