Ejemplo n.º 1
0
        /// <summary>
        /// method to parse multitext defined in only one line
        /// </summary>
        /// <param name="config">config structure</param>
        /// <param name="tableName">name of table</param>
        /// <param name="column">name of column in db</param>
        /// <param name="line">a line in names</param>
        /// <param name="nameLine">a line in names</param>
        /// <param name="names">names which will contains name in all langs</param>
        private static string parseMultitextLine(CIniFile config, string tableName, string column, string line, List <string> nameLine, string[] names)
        {
            //Textlist on a tag
            int    multitextIndex = nameLine.FindIndex(s => s.Contains("multitext"));
            string TextListName   = nameLine[multitextIndex + 1].Trim();

            ColumnTextlistDefine.Add(column, TextListName); //To add textlist into helper class
            //Only add rest of tag also into NameDef
            string[] eqeuateSplit = line.Split(Const.separ_equate, StringSplitOptions.RemoveEmptyEntries);
            string[] langs        = eqeuateSplit[1].Split(Const.separ_dollar, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < langs.Length; i++)
            {
                string[] parts = langs[i].Split(Const.separ_semicolon, StringSplitOptions.RemoveEmptyEntries);
                names[i] = parts[0];
            }
            List <string> units = null;                                  //yes add only null

            NameDefinition.Add(config, column, names, units, tableName); //Adds name to names
            return(TextListName);
        }
Ejemplo n.º 2
0
        private int parseNameDefinition(CIniFile config, string[] separators, string[] lines, int startLineIdx)
        {
            string[]        nameLine        = null, nameLineFirstPart = null, nameLineLangMutate = null;
            string          tableName       = null;
            List <string[]> multitext_lines = new List <string[]>();

            for (int i = startLineIdx; i < lines.Length; i++)
            {
                List <string> units = new List <string>();
                string[]      langs = new string[config.LangEnbList.Count];
                if (!(lines[i].StartsWith("#")) && (lines[i].Length != 0))
                {
                    nameLine           = lines[i].Split(Const.separ_equate, StringSplitOptions.RemoveEmptyEntries);
                    nameLineFirstPart  = nameLine[0].Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    nameLineLangMutate = nameLine[1].Split(Const.separ_names, StringSplitOptions.RemoveEmptyEntries);
                    foreach (CView view in config.ViewList)
                    {
                        foreach (CField field in view.FieldList)
                        {
                            foreach (CSignal signal in field.SigList)
                            {
                                if (signal.column.Contains(nameLineFirstPart[1]))
                                {
                                    tableName = signal.table;
                                }
                            }
                        }
                    }
                    int j = 0;
                    for (int idx = 0; idx < nameLineLangMutate.Length; idx = idx + 2)
                    {
                        if (!(nameLineLangMutate[idx + 1].Contains(@"\")) && !(nameLineLangMutate[idx + 1].Contains("multitext:")))
                        {
                            if (nameLineLangMutate.Length > config.LangEnbList.Count)
                            {
                                langs[j] = nameLineLangMutate[idx];
                                units.Insert(j, nameLineLangMutate[idx + 1]);
                                j++;
                            }
                            else
                            {
                                langs[j] = nameLineLangMutate[idx];
                                j++;
                            }
                        }
                        else
                        {
                            langs[j] = nameLineLangMutate[idx];
                            if (!(nameLineLangMutate[idx + 1].Contains("multitext:")))
                            {
                                multitextInline(config, tableName, nameLine[1]);
                                idx = nameLineLangMutate.Length;
                            }
                            else
                            {
                                int    pos          = nameLineLangMutate[idx + 1].LastIndexOf(":");
                                string TextlistName = nameLineLangMutate[idx + 1].Substring(pos + 1);
                                ColumnTextlistDefine.Add(nameLineFirstPart[1], TextlistName);
                            }
                            j++;
                        }
                    }
                    NameDefinition.Add(config, nameLineFirstPart[1], langs, units, tableName);
                }
                else
                {
                    return(i);
                }
            }
            return(0);
        }