コード例 #1
0
        /// <summary>
        /// Create a list of key value grouped by GID
        /// </summary>
        /// <param name="LoopIDToExtract">Value to extract</param>
        /// <returns>A list that contains all Key and Values into strings</returns>
        private List <StructValueList> ExtractValues(int LoopIDToExtract)
        {
            List <StructValueList> RetNotSorted = null;
            StructValueList        ValueToAdd;
            bool IsValueAdded = false;

            if (_Items != null)
            {
                // Read all items and try to add values into list
                foreach (StructuredFileKey CurrentValue in _Items)
                {
                    // Clear added flags
                    IsValueAdded = false;

                    // Check if current value is included in a loop
                    if (CurrentValue.GetLoopID() == LoopIDToExtract)
                    {
                        int CaseID = CurrentValue.GetLoopID() * 100 + CurrentValue.GetGID();

                        if (RetNotSorted == null)
                        {
                            RetNotSorted = new List <StructValueList>();
                            IsValueAdded = false;
                        }
                        else
                        {
                            // Read all ValueList and add the current value (and key) into the correct loop
                            for (int i = 0; i < RetNotSorted.Count(); i++)
                            {
                                if (RetNotSorted[i].CaseID == CaseID)
                                {
                                    ValueToAdd.CaseID    = CaseID;
                                    ValueToAdd.KeyList   = RetNotSorted[i].KeyList + "|" + CurrentValue.GetName();
                                    ValueToAdd.ValueList = RetNotSorted[i].ValueList + "|" + CurrentValue.GetValue();

                                    RetNotSorted[i] = ValueToAdd;

                                    IsValueAdded = true;
                                }
                            }
                        }

                        // If current value has not been added, we create a new entry
                        if (IsValueAdded == false)
                        {
                            // Create the new entry
                            ValueToAdd.CaseID    = CaseID;
                            ValueToAdd.KeyList   = CurrentValue.GetName();
                            ValueToAdd.ValueList = CurrentValue.GetValue();

                            RetNotSorted.Add(ValueToAdd);
                        }
                    }
                }
            }

            return(RetNotSorted);
        }