Files
UnrealEngineUWP/Engine/Source/Programs/AutomationTool/OneSkyLocalization/OneSkyConfigHelper.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

84 lines
2.4 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using AutomationTool;
using UnrealBuildTool;
namespace EpicGames.OneSkyLocalization.Config
{
/// <summary>
/// Class for retrieving OneSky localization configuration data
/// </summary>
public class OneSkyConfigHelper
{
// List of configs is cached off for fetching from multiple times
private static Dictionary<string, OneSkyConfigData> Configs;
public static OneSkyConfigData Find(string ConfigName)
{
if (Configs == null)
{
// Load all secret configs by trying to instantiate all classes derived from OneSkyConfigData from all loaded DLLs.
// Note that we're using the default constructor on the secret config types.
Configs = new Dictionary<string, OneSkyConfigData>();
Assembly[] LoadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var Dll in LoadedAssemblies)
{
Type[] AllTypes = Dll.GetTypes();
foreach (var PotentialConfigType in AllTypes)
{
if (PotentialConfigType != typeof(OneSkyConfigData) && typeof(OneSkyConfigData).IsAssignableFrom(PotentialConfigType))
{
try
{
OneSkyConfigData Config = Activator.CreateInstance(PotentialConfigType) as OneSkyConfigData;
if (Config != null)
{
Configs.Add(Config.Name, Config);
}
}
catch
{
BuildCommand.LogWarning("Unable to create OneSky config data: {0}", PotentialConfigType.Name);
}
}
}
}
}
OneSkyConfigData LoadedConfig;
Configs.TryGetValue(ConfigName, out LoadedConfig);
if (LoadedConfig == null)
{
throw new AutomationException("Unable to find requested OneSky config data: {0}", ConfigName);
}
return LoadedConfig;
}
}
/// <summary>
/// Class for storing OneSky Localization configuration data
/// </summary>
public class OneSkyConfigData
{
public OneSkyConfigData(string InName, string InApiKey, string InApiSecret)
{
Name = InName;
ApiKey = InApiKey;
ApiSecret = InApiSecret;
}
public string Name;
public string ApiKey;
public string ApiSecret;
public void SpewValues()
{
CommandUtils.LogInformation("Name : {0}", Name);
CommandUtils.LogInformation("ApiKey : {0}", ApiKey);
//CommandUtils.LogConsole("ApiSecret : {0}", ApiSecret); // This should probably never be revealed.
}
}
}