Exemple #1
0
 /// <summary>
 /// Fills the mappedPicklists Dictionary with a key that is the combination of a data category and a content, and a boolean value.
 /// <para>
 /// Any content values which are mapped to TBX data categories which do not have picklists will be skipped.
 /// </para>
 /// <para>
 /// <code>{ 'part of speech_noun' : false }</code>
 /// </para>
 /// <para>
 /// This means that the content "noun" of "part of speech" has not been mapped to a TBX picklist value yet.
 /// </para>
 /// </summary>
 private void FillMappedPicklistsDict()
 {
     dcs_with_picklists.ForEach(delegate(string dc)
     {
         foreach (string val in mapping.GetContentList(dc))
         {
             string[] keys = Methods.GetKeyArray(tbx_picklists.Keys);
             if (mapping.GetTBXMappingList(dc).Count < 2 || Array.Exists(keys, item => item == mapping.GetTBXContentMap(dc)?.Get(val)))
             {
                 try
                 {
                     mappedPicklists.Add(dc + "_" + val, false);
                 }
                 catch (ArgumentException)
                 {
                     continue;
                 }
             }
         }
     });
 }
        private void LoadDatCats()
        {
            XmlReaderSettings settings = new XmlReaderSettings
            {
                DtdProcessing = DtdProcessing.Ignore
            };
            XmlReader reader = XmlReader.Create(filename, settings);

            bool start = false;
            int  level = 0;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && (reader.Name == "body" || reader.Name == "mtf"))
                {
                    start = true;
                }
                if (start == true)
                {
                    if (reader.Name == "back")
                    {
                        start = false;
                        continue;
                    }

                    if (reader.Name == "conceptGrp" || reader.Name == "languageGrp" || reader.Name == "termGrp" ||
                        reader.Name == "termEntry" || reader.Name == "langSet" || reader.Name == "tig" ||
                        reader.Name == "conceptEntry" || reader.Name == "langSec" || reader.Name == "termSec")
                    {
                        switch (reader.Name)
                        {
                        case "conceptGrp":
                        case "termEntry":
                        case "conceptEntry":
                            level = 1;
                            break;

                        case "languageGrp":
                        case "langSet":
                        case "langSec":
                            level = 2;
                            break;

                        case "termGrp":
                        case "tig":
                        case "termSec":
                            level = 3;
                            break;
                        }
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.HasAttributes && null != reader.GetAttribute("type") && reader.Name != "language")
                    {
                        string dc = reader.GetAttribute("type");
                        if (!datcats.Contains(dc))
                        {
                            datcats.Add(dc);
                            mapping.Add(dc);

                            switch (level)
                            {
                            case 1:
                                mapping.LevelMap["conceptGrp"].Add(dc);
                                break;

                            case 2:
                                mapping.LevelMap["languageGrp"].Add(dc);
                                break;

                            case 3:
                                mapping.LevelMap["termGrp"].Add(dc);
                                break;
                            }
                        }

                        //Pull out text for use later with picklists
                        XmlReader textReader = reader.ReadSubtree();

                        while (textReader.Read())
                        {
                            if (textReader.NodeType == XmlNodeType.Text)
                            {
                                List <string> values = mapping.GetContentList(dc) as List <string>;
                                if (!values.Contains(reader.Value))
                                {
                                    mapping.GetContentList(dc).Add(textReader.Value);
                                }
                            }
                        }
                    }
                }
            }

            datcats.Sort();
            textTotal.Text = datcats.Count().ToString();
        }