Example #1
0
 private static Locomotive GetLocomotiveReverse(ConsistFile conFile, Folder folder)
 {
     foreach (var wagon in conFile.Train.Wagons.Where(w => w.IsEngine))
     {
         try
         {
             return(Locomotive.GetLocomotive(folder.ContentFolder.EngineFile(wagon.Folder, wagon.Name)));
         }
         catch { }
     }
     return(null);
 }
Example #2
0
 private Consist(ConsistFile consist, Locomotive locomotive, string fileName)
 {
     Locomotive = locomotive;
     if (string.IsNullOrEmpty(consist.Name))
     {
         Name = $"<{catalog.GetString("unnamed:")} {System.IO.Path.GetFileNameWithoutExtension(fileName)}>";
     }
     else
     {
         Name = consist.Name?.Trim();
     }
     FilePath = fileName;
 }
Example #3
0
        internal static async Task <Consist> FromFileAsync(string fileName, Folder folder, bool reverseConsist, CancellationToken token)
        {
            return(await Task.Run(() =>
            {
                Consist result = null;

                try
                {
                    ConsistFile conFile = new ConsistFile(fileName);
                    Locomotive locomotive = reverseConsist ? GetLocomotiveReverse(conFile, folder) : GetLocomotive(conFile, folder);
                    if (locomotive != null)
                    {
                        result = new Consist(conFile, locomotive, fileName);
                    }
                }
                catch
                {
                    result = new Consist($"<{catalog.GetString("load error:")} {System.IO.Path.GetFileNameWithoutExtension(fileName)}>", fileName);
                }
                return result;
            }, token).ConfigureAwait(false));
        }