예제 #1
0
        /// <summary>
        /// This method privides to load values into dictionary (specifically into
        /// a String key and DefinitionTag object / value(s).
        /// This method ignores the first rows of config file and store:
        /// <list type="">
        /// <item>Key: that is the DefinitionTag class Tag property.</item>
        /// <item>Value: that is the DefinitionTag class Value property.</item>
        /// <item>Description: that is Description class property.</item>
        /// </list>
        /// </summary>
        /// <param name="TextData">Represents an array of strings</param>
        /// <returns>A dictionary loaded of array strings.</returns>
        public static Dictionary <String, DefinitionTag> SplitDataInDictionary(String[] TextData)
        {
            Dictionary <String, DefinitionTag> myRet = new Dictionary <String, DefinitionTag>();
            Int32         nrRow   = 0;
            String        myCh    = String.Empty;
            StringBuilder sb      = new StringBuilder();
            Int32         fistRow = Helper.getFirstRowReadable(TextData);

            foreach (String row in TextData)
            {
                if (nrRow > fistRow)
                {
                    myCh = StringExtensions.Left(row, Constants.K_ColumnDescriptionHidden).Trim();
                    if (myCh == Constants.K_CharDescription)
                    {
                        sb = sb.AppendLine(Helper.replaceFirst(row, Constants.K_CharDescription, ""));
                    }
                    else if (myCh == Constants.K_CharDescriptionAlt)
                    {
                        //NOP
                    }
                    else if (myCh.Length > 0)
                    {
                        //kCharDivideKeyValue[0] --> from string to char
                        String[] tokens        = row.Split(Constants.K_CharDivideKeyValue[0]).Select(x => x.Trim()).ToArray();
                        String   myDescription = sb.ToString().Trim();

                        DefinitionTag def = new DefinitionTag();

                        String tmpTag = tokens[0].ToString();

                        switch (tmpTag)
                        {
                        case Constants.K_FILE_PATTERNS:
                            def.Value = makeMultiValuesString(Constants.K_FILE_PATTERNS, nrRow, TextData);
                            break;

                        case Constants.K_ABBREVIATE_BRIEF:
                            def.Value = makeMultiValuesString(Constants.K_ABBREVIATE_BRIEF, nrRow, TextData);
                            break;

                        default:
                            def.Value = tokens[1].ToString().Replace("\"", "");
                            break;
                        }

                        def.Description = myDescription;
                        myRet.Add(tokens[0], def);
                        sb.Clear();
                    }
                    else
                    {
                        //NOP
                    }
                }
                nrRow++;
            }

            return(myRet);
        }
예제 #2
0
        //TODO: data integrity -- END

        /// <summary>
        /// This method update a custom tag value by creating a new DefinitionTag object.
        /// </summary>
        /// <param name="TAG">Represents a tag as key</param>
        /// <param name="NewValue">Represents a new value property.</param>
        /// <param name="Description">Represents a description property.</param>
        /// <param name="Dictionary">Represents a reference dictionary.</param>
        public static void UpdateCustomValue(String TAG, String NewValue, String Description, ref Dictionary <String, DefinitionTag> Dictionary)
        {
            DefinitionTag dd = new DefinitionTag();

            dd.Tag         = TAG;
            dd.Value       = NewValue;
            dd.Description = Description;

            Dictionary[TAG] = dd;
        }
예제 #3
0
        /// <summary>
        /// This method takes a dictionary parameter and copy key/value pairs
        /// (value is a DefinitionTag object)
        /// </summary>
        /// <param name="original">It Represents the dicionary we want to clone</param>
        /// <returns>Returns a new copied dictionary</returns>
        public static Dictionary <String, DefinitionTag> CopyDictionary(Dictionary <String, DefinitionTag> original)
        {
            Dictionary <String, DefinitionTag> ret = new Dictionary <String, DefinitionTag>();

            foreach (KeyValuePair <String, DefinitionTag> entry in original)
            {
                DefinitionTag dd = new DefinitionTag();
                dd = entry.Value;
                ret.Add(entry.Key, dd);
            }
            return(ret);
        }