public void InitTS1() { var floorGlobalsPath = Path.Combine(ContentManager.TS1BasePath, "GameData/floors.iff"); var floorGlobals = new IffFile(floorGlobalsPath); FloorGlobals = floorGlobals; var buildGlobalsPath = Path.Combine(ContentManager.TS1BasePath, "GameData/Build.iff"); BuildGlobals = new IffFile(buildGlobalsPath); //todo: centralize? InitGlobals(); //load *.flr iffs from both the TS1 provider and folder ushort floorID = 256; var files = new FileProvider <IffFile>(ContentManager, new IffCodec(), new Regex(".*/Floors.*\\.flr")); files.UseTS1 = true; var ts1 = new TS1SubProvider <IffFile>(ContentManager.TS1Global, ".flr"); files.Init(); ts1.Init(); var compo = new CompositeProvider <IffFile>(new List <IContentProvider <IffFile> >() { ts1, files }); Floors = compo; var all = compo.ListGeneric(); foreach (var entry in all) { var iff = (IffFile)entry.GetThrowawayGeneric(); DynamicFloorFromID[Path.GetFileNameWithoutExtension(entry.ToString().Replace('\\', '/')).ToLowerInvariant()] = floorID; var catStrings = iff.Get <STR>(0); Entries.Add(floorID, new FloorReference(this) { ID = floorID, FileName = Path.GetFileName(entry.ToString().Replace('\\', '/')).ToLowerInvariant(), Name = catStrings.GetString(0), Price = int.Parse(catStrings.GetString(1)), Description = catStrings.GetString(2) }); floorID++; } NumFloors = floorID; }
public async Task Throws_when_PUT_without_known_resource_provider() { var composite = new CompositeProvider(new IResourceProvider[] { new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new[] { ResourceProvider.DefaultScheme }) { { "blub:123", "blub1" } }, new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new[] { ResourceProvider.DefaultScheme }) { { "blub:123?providerName=blub", "blub2" }, { "blub:123?providerName=blub", "blub3" } }, }); await Assert.ThrowsAnyAsync <DynamicException>(async() => await composite.PutAsync("blub:123", Stream.Null)); }
public async Task Can_get_resource_by_scheme() { var composite = new CompositeProvider(new IResourceProvider[] { new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new SoftString[] { "bluba" }) { { "x.123", "blub1" } }, new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new SoftString[] { "blub" }) { { "x.123", "blub2" }, { "x.125", "blub3" } }, }); var resource = await composite.GetAsync("blub:x/123"); Assert.True(resource.Exists); Assert.Equal("blub2", await resource.DeserializeTextAsync()); }
public async Task Can_get_resource_by_custom_name() { var composite = new CompositeProvider(new IResourceProvider[] { new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new[] { ResourceProvider.DefaultScheme }) { { "x.123", "blub1" } }, new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new[] { ResourceProvider.DefaultScheme }, ImmutableSession.Empty.Set(Use <IProviderNamespace> .Namespace, x => x.CustomName, "blub")) { //{ "x.123", "blub2" }, { "x.123", "blub3" } }, }); var resource = await composite.GetAsync("blub:x/123", ImmutableSession.Empty.Set(Use <IProviderNamespace> .Namespace, x => x.CustomName, "blub")); Assert.True(resource.Exists); Assert.Equal("blub3", await resource.DeserializeTextAsync()); }
public async Task Gets_first_matching_resource_by_default() { var composite = new CompositeProvider(new IResourceProvider[] { new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new[] { ResourceProvider.DefaultScheme }) { { "x.123", "blub1" } }, new InMemoryProvider(new UriStringToSettingIdentifierConverter(), new[] { ResourceProvider.DefaultScheme }) { { "x.123", "blub2" }, { "x.123", "blub3" } }, }); var resource = await composite.GetAnyAsync("blub:x/123"); Assert.True(resource.Exists); Assert.Equal("blub1", await resource.DeserializeTextAsync()); }
public static void Main(string[] args) { Console.WriteLine(Resource.GetString("Initialize.txt")); Console.WriteLine(); InitializeLogger(); var provider = new CompositeProvider( new BloodCatBeatmapProvider(), new OsuBeatmapProvider("86a40fb966ffaaf1ed3f996d3b50bb0f2a027661") ); while (true) { var process = FindTargetProcess(); Log.Information("Found {target} process({pid})", processTarget, process.Id); using var service = new BeatmapDownloadService(process, provider); service.DownloadStarted += ServiceOnDownloadStarted; service.DownloadProgressChanged += ServiceOnDownloadProgressChanged; service.DownloadCompleted += ServiceOnDownloadCompleted; service.DownloadFailed += ServiceOnDownloadFailed; service.Start(); while (!process.HasExited) { Thread.Sleep(500); } Log.Information("{target} process({pid}) closed", processTarget, process.Id); Console.WriteLine(); } }
protected override void SetUp() { provider = new CompositeProvider<object>(); }