Exemplo n.º 1
0
        public static Dictionary <string, TAgroup> GetAllTAgroups()
        {
            string path = @"Plugins\DLS\Traffic Advisory\";

            _ = new TAgroup();
            Dictionary <string, TAgroup> listTAgroups = new Dictionary <string, TAgroup>();

            foreach (string file in Directory.EnumerateFiles(path, "*.xml"))
            {
                try
                {
                    XmlSerializer mySerializer = new XmlSerializer(typeof(TAgroup));
                    StreamReader  streamReader = new StreamReader(file);

                    TAgroup taGroup = (TAgroup)mySerializer.Deserialize(streamReader);
                    streamReader.Close();

                    string name = Path.GetFileNameWithoutExtension(file);

                    listTAgroups.Add(name, taGroup);
                    ("Added TAgroup: " + name).ToLog();
                }
                catch (Exception e)
                {
                    ("TAGROUP IMPORT ERROR (" + Path.GetFileNameWithoutExtension(file) + "): " + e.Message).ToLog();
                    Game.LogTrivial("TAGROUP IMPORT ERROR (" + Path.GetFileNameWithoutExtension(file) + "): " + e.Message);
                }
            }
            return(listTAgroups);
        }
Exemplo n.º 2
0
 internal static int GetIndexFromTAPatternName(this TAgroup taGroup, string name)
 {
     foreach (TApattern taP in taGroup.TaPatterns)
     {
         if (taP.Name == name)
         {
             return(taGroup.TaPatterns.IndexOf(taP));
         }
     }
     return(999);
 }