public static void ImportSubRaces(this OGLContext context) { if (context == null || context.Config == null) { return; } context.SubRaces.Clear(); context.SubRacesSimple.Clear(); var files = SourceManager.EnumerateFiles(context, context.Config.SubRaces_Directory, SearchOption.TopDirectoryOnly); foreach (var f in files) { try { using (TextReader reader = new StreamReader(f.Key.FullName)) { SubRace s = (SubRace)SubRace.Serializer.Deserialize(reader); s.Source = f.Value; s.Register(context, f.Key.FullName); } } catch (Exception e) { ConfigManager.LogError("Error reading " + f.ToString(), e); } } }
public async static Task ImportSubRacesAsync(this OGLContext context) { context.SubRaces.Clear(); context.SubRacesSimple.Clear(); var files = await PCLSourceManager.EnumerateFilesAsync(context, context.Config.SubRaces_Directory).ConfigureAwait(false); foreach (var f in files) { try { using (Stream reader = await f.Key.OpenAsync(FileAccess.Read).ConfigureAwait(false)) { SubRace s = (SubRace)SubRace.Serializer.Deserialize(reader); s.Source = f.Value; s.Register(context, f.Key.Path); } } catch (Exception e) { ConfigManager.LogError("Error reading " + Path(f.Key.Path), e); } } }