예제 #1
0
파일: Consists.cs 프로젝트: Reve/ORTS-MG
 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);
 }
예제 #2
0
파일: Consists.cs 프로젝트: Reve/ORTS-MG
 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;
 }
예제 #3
0
파일: Consists.cs 프로젝트: Reve/ORTS-MG
        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));
        }