public void Save(IGeneralConfig config, IFileSystem disk, IJsonUtil jsonUtil) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (disk == null) { throw new ArgumentNullException(nameof(disk)); } if (jsonUtil == null) { throw new ArgumentNullException(nameof(jsonUtil)); } var path = config.ResolvePath(UserPath); var dir = Path.GetDirectoryName(path); if (!disk.DirectoryExists(dir)) { disk.CreateDirectory(dir); } var json = jsonUtil.Serialize(this); disk.WriteAllText(path, json); }
ISerializer Search(string dir, IGeneralConfig generalConfig, AssetInfo info) { var combined = Path.Combine(dir, info.File.Filename); var filename = Path.GetFileName(combined).ToUpperInvariant(); dir = Path.GetDirectoryName(combined); var resolved = generalConfig.ResolvePath(dir); if (!Directory.Exists(resolved)) { return(null); } var directory = Path.Combine(resolved, filename); if (Directory.Exists(directory)) { var s = _containerLoaderRegistry.Load(directory, info, ContainerFormat.Directory); if (s != null) { return(s); } } var files = Directory.GetFiles(resolved); foreach (var path in files.Where(x => Path.GetFileNameWithoutExtension(x).ToUpperInvariant() == filename)) { if (info.File.Sha256Hashes != null) { var hash = GetHash(path); if (info.File.Sha256Hashes.All(x => !hash.Equals(x, StringComparison.OrdinalIgnoreCase))) { var expected = string.Join(", ", info.File.Sha256Hashes); CoreUtil.LogWarn( $"Found file {path} for asset {info.AssetId}, but its " + $"hash ({hash}) did not match any of the expected ones ({expected})"); return(null); } } ISerializer s; var extension = Path.GetExtension(path).ToUpperInvariant(); switch (extension) { case ".XLD": s = _containerLoaderRegistry.Load(path, info, ContainerFormat.Xld); break; case ".ZIP": s = _containerLoaderRegistry.Load(path, info, ContainerFormat.Zip); break; default: s = _containerLoaderRegistry.Load(path, info, info.File.ContainerFormat); break; } if (s != null) { return(s); } } return(null); }
public Startup(IConfiguration configuration) { Configuration = configuration; GeneralConfig = new GeneralConfig(); GeneralConfig.ConnectionString = Configuration["ConnectionStrings:CGPComprasConnectionString"]; GeneralConfig.ApiUrl = Configuration["Urls:ApiUrl"]; GeneralConfig.WebUrl = Configuration["Urls:WebUrl"]; }
private static void GenerateNewGeneralConfig(IGeneralConfig GConfig) { var configJson = JsonConvert.SerializeObject(GConfig); Console.WriteLine("Creating config.json"); generalConfigFile.Delete(); File.WriteAllText(generalConfigFile.FullName, configJson); generalConfigFile = new FileInfo(generalConfigFile.FullName); }
public TranscribeDataService(IAmazonDynamoDB cli, IGeneralConfig cfg) { Client = cli; AppConfig = cfg; DyConfig = new DynamoDBOperationConfig { OverrideTableName = cfg.TableName }; }
/// <summary> /// Starts Program and runs infinitely. /// </summary> public async Task Start() { IGeneralConfig config = await new GeneralConfigReader().ReadAsync(); await ConfigureAndStart(config); while (true) { // Just spin } }
private static void _saveModule(ModuleDefMD module, IGeneralConfig config) { ModuleWriterOptions moduleWriterOptions = null; if (!String.IsNullOrWhiteSpace(config.SnkPath)) { moduleWriterOptions = new ModuleWriterOptions(module); moduleWriterOptions.InitializeStrongNameSigning(module, new StrongNameKey(config.SnkPath)); } module.Write( filename: Path.Combine(config.OutputPath, new FileInfo(module.Location).Name), options: moduleWriterOptions ); }
public void LoadMods(IGeneralConfig config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } _mods.Clear(); _modsInReverseDependencyOrder.Clear(); AssetMapping.Global.Clear(); foreach (var mod in Resolve <IGameplaySettings>().ActiveMods) { LoadMod(config.ResolvePath("$(MODS)"), mod); } _modsInReverseDependencyOrder.Reverse(); }
private async Task ConfigureAndStart(IGeneralConfig config) { Credentials = new Credentials(config.AzubiIdentNr.ToString(), config.PrüflingsNr.ToString()); Timer t = GetTimer(config.RepeatRunSpan); if (config.UseMailNotifications) { MailSender = new MailSender(); Results = await GetResultsAsync(); NewResults += async(object obj, EventArgs e) => { await MailSender.SendResultsAsync(obj, e, Results); }; } if (config.NotifyOnStartup) { OnNewResults(null); } }
object TryLoad(string dir, IGeneralConfig generalConfig, AssetInfo info, SerializationContext context) { using var s = Search(dir, generalConfig, info); if (s == null) { return(null); } if (s.BytesRemaining == 0) // Happens all the time when dumping, just return rather than throw to preserve perf. { return(new AssetNotFoundException($"Asset for {info.AssetId} found but size was 0 bytes.", info.AssetId)); } var loader = _assetLoaderRegistry.GetLoader(info.File.Loader); if (loader == null) { throw new InvalidOperationException($"No loader for file type \"{info.File.Loader}\" required by asset {info.Name}"); } return(loader.Serdes(null, info, context.Mapping, s)); }
public static GeneralSettings Load(IGeneralConfig config, IFileSystem disk, IJsonUtil jsonUtil) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (disk == null) { throw new ArgumentNullException(nameof(disk)); } if (jsonUtil == null) { throw new ArgumentNullException(nameof(jsonUtil)); } var path = config.ResolvePath(UserPath); if (!disk.FileExists(path)) { path = config.ResolvePath(DefaultsPath); } if (!disk.FileExists(path)) { throw new FileNotFoundException($"Could not find default settings file (expected at {path})"); } var settings = disk.FileExists(path) ? jsonUtil.Deserialize <GeneralSettings>(disk.ReadAllBytes(path)) : new GeneralSettings(); if (!settings.ActiveMods.Any()) { settings.ActiveMods.Add("Base"); } return(settings); }
public RecordingsModel(ITranscribeDataService svc, IFileService fsvc, IGeneralConfig cfg) { TranSvc = svc; FileSvc = fsvc; Config = cfg; }
public FileService(IAmazonS3 s3, IGeneralConfig config) { Config = config; S3Client = s3; }
public void LoadMods(IGeneralConfig config) { }