private ConvertResult convert(string name, Mod[] mods)
        {
            var beatmap = GetBeatmap(name);

            var converterResult = new Dictionary <HitObject, IEnumerable <HitObject> >();

            var working = new ConversionWorkingBeatmap(beatmap)
            {
                ConversionGenerated = (o, r, c) =>
                {
                    converterResult[o] = r;
                    OnConversionGenerated(o, r, c);
                }
            };

            working.GetPlayableBeatmap(CreateRuleset().RulesetInfo, mods);

            return(new ConvertResult
            {
                Mappings = converterResult.Select(r =>
                {
                    var mapping = CreateConvertMapping(r.Key);
                    mapping.StartTime = r.Key.StartTime;
                    mapping.Objects.AddRange(r.Value.SelectMany(CreateConvertValue));
                    return mapping;
                }).ToList()
            });
        }
Exemple #2
0
        private ConvertResult convert(string name, Mod[] mods)
        {
            var conversionTask = Task.Factory.StartNew(() =>
            {
                var beatmap = GetBeatmap(name);

                string beforeConversion = beatmap.Serialize();

                var converterResult = new Dictionary <HitObject, IEnumerable <HitObject> >();

                var working = new ConversionWorkingBeatmap(beatmap)
                {
                    ConversionGenerated = (o, r, c) =>
                    {
                        converterResult[o] = r;
                        OnConversionGenerated(o, r, c);
                    }
                };

                working.GetPlayableBeatmap(CreateRuleset().RulesetInfo, mods);

                string afterConversion = beatmap.Serialize();

                Assert.AreEqual(beforeConversion, afterConversion, "Conversion altered original beatmap");

                return(new ConvertResult
                {
                    Mappings = converterResult.Select(r =>
                    {
                        var mapping = CreateConvertMapping(r.Key);
                        mapping.StartTime = r.Key.StartTime;
                        mapping.Objects.AddRange(r.Value.SelectMany(CreateConvertValue));
                        return mapping;
                    }).ToList()
                });
            }, TaskCreationOptions.LongRunning);

            if (!conversionTask.Wait(10000))
            {
                Assert.Fail("Conversion timed out");
            }

            return(conversionTask.GetResultSafely());
        }