Beispiel #1
0
 public void AddValue(string FileId, string paramValue)
 {
     try
     {
         ParamValue existingValue = this.Values.Find(v => v.FileId == FileId);
         if (existingValue == null)
         {
             Values.Add(new ParamValue(FileId, paramValue));
         }
         else
         {
             throw new InvalidOperationException("Cannot add duplicates to Values property");
         }
     }
     catch (InvalidOperationException e)
     {
         Console.WriteLine("Error caught while trying to use Entry.AddValue method: {0}", e.Message);
     }
 }
Beispiel #2
0
        /// <summary> Transform list of entries into 2D array. </summary>
        /// <remarks> Tplateus, 3/01/2018. </remarks>
        /// <param name="Entries"> The entries. </param>
        /// <param name="FileIds"> List of identifiers for the files (for the headers). </param>
        /// <param name="configuration">Configuration string for working with paramLists or paramTables=.</param>
        /// <returns> A 2D array of strings. </returns>
        private string[,] TransformInto2DArray(List <Entry> Entries, List <string> FileIds, string configuration = "list")
        {
            List <string> headers = new List <string> {
                "SetName", "ListName", "ParamName", "ConfigName"
            };

            if (configuration == "table")
            {
                headers = new List <string> {
                    "SetName", "TableName", "Position", "ColumnName", "ConfigName"
                };
            }

            int nParams = headers.Count;

            headers.AddRange(FileIds);

            int rowCount = Entries.Count + 1;
            int colCount = headers.Count;

            //Make an array of strings with dimension rowCount+1 (add 1 row for headers) and colCount+4 (add 4 rows for identifiers).
            string[,] matrix = new string[rowCount, colCount];
            for (int i = 0; i < colCount; i++)
            {
                matrix[0, i] = headers[i];
            }

            for (int i = 1; i < rowCount; i++)
            {
                Entry entry = Entries[i - 1];
                if (configuration == "list")
                {
                    matrix[i, 0] = entry.SetName;
                    matrix[i, 1] = entry.ContainerName;
                    matrix[i, 2] = entry.ParamName;
                    matrix[i, 3] = entry.ConfigName;
                }
                else
                {
                    matrix[i, 0] = entry.SetName;
                    matrix[i, 1] = entry.ContainerName;
                    matrix[i, 2] = entry.Position;
                    matrix[i, 3] = entry.ParamName;
                    matrix[i, 4] = entry.ConfigName;
                }


                for (int j = nParams; j < colCount; j++)
                {
                    string id = FileIds[j - nParams];

                    ParamValue val = entry.Values.Find(v => v.FileId == id);
                    if (val != null)
                    {
                        matrix[i, j] = val.Value;
                    }
                    else
                    {
                        matrix[i, j] = "!NOT_FOUND";
                    }
                }
            }
            return(matrix);
        }