Files
UnrealEngineUWP/Engine/Source/Programs/nDisplayLauncher/Cluster/Config/Conversion/ConfigConversion.cs
Ryan Durand 9ef3748747 Updating copyrights for Engine Programs.
#rnx
#rb none
#jira none

#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869242 in //Fortnite/Release-12.00/... via CL 10869536
#ROBOMERGE-BOT: FORTNITE (Main -> Dev-EngineMerge) (v613-10869866)

[CL 10870955 by Ryan Durand in Main branch]
2019-12-26 23:01:54 -05:00

61 lines
1.5 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using nDisplayLauncher.Log;
using nDisplayLauncher.Cluster.Config.Conversion.Converters;
namespace nDisplayLauncher.Cluster.Config.Conversion
{
public static class ConfigConversion
{
public class ConversionResult
{
public bool Success = false;
public string NewConfigFile = string.Empty;
}
public static ConversionResult Convert(string OrigFile, ConfigurationVersion ToVerison)
{
ConversionResult Result = new ConversionResult();
ConfigurationVersion Ver = Parser.GetVersion(OrigFile);
try
{
string OldFile = OrigFile;
for (int i = (int)Ver + 1; i <= (int)Launcher.CurrentVersion; ++i)
{
Result.NewConfigFile = OldFile.Insert(OldFile.Length - ".cfg".Length, "." + ((ConfigurationVersion)i).ToString());
IConfigConverter Converter = ConverterFactory.CreateConverter((ConfigurationVersion)i);
if (Converter == null)
{
AppLogger.Log("Unknown config format");
return Result;
}
Result.Success = Converter.Convert(OldFile, Result.NewConfigFile);
if (!Result.Success)
{
throw new Exception(string.Format("Couldn't convert\n%s\n\to\n%s", OldFile, Result.NewConfigFile));
}
OldFile = Result.NewConfigFile;
}
}
catch (Exception ex)
{
AppLogger.Log("Conversion error: " + ex.Message);
}
return Result;
}
}
}