Exemplo n.º 1
0
        /// <summary> Loads the .dll files from the current directory + relative path ("/checks" by default). </summary>
        public static void LoadCheckDLLs()
        {
            CheckerRegistry.ClearChecks();

            Parallel.ForEach(GetCheckDLLPaths(), aDllPath =>
            {
                Track dllTrack = new Track("Loading checks from \"" + aDllPath.Split('/', '\\').Last() + "\"...");

                LoadCheckDLL(aDllPath);

                dllTrack.Complete();
            });
        }
Exemplo n.º 2
0
        /// <summary> Returns a list of issues sorted by level, in the given beatmap set. </summary>
        public static List <Issue> GetBeatmapSetIssues(BeatmapSet aBeatmapSet)
        {
            if (!CheckerRegistry.GetChecks().Any())
            {
                LoadCheckDLLs();
            }

            ConcurrentBag <Issue> issueBag = new ConcurrentBag <Issue>();

            TryGetIssuesParallel(CheckerRegistry.GetGeneralChecks(), aGeneralCheck =>
            {
                foreach (Issue issue in aGeneralCheck.GetIssues(aBeatmapSet).OrderBy(anIssue => anIssue.level).Reverse())
                {
                    issueBag.Add(issue.WithOrigin(aGeneralCheck));
                }
            });

            Parallel.ForEach(aBeatmapSet.beatmaps, aBeatmap =>
            {
                Track beatmapTrack = new Track("Checking for issues in " + aBeatmap + "...");

                TryGetIssuesParallel(CheckerRegistry.GetBeatmapChecks(), aBeatmapCheck =>
                {
                    if (((BeatmapCheckMetadata)aBeatmapCheck.GetMetadata()).Modes.Contains(aBeatmap.generalSettings.mode))
                    {
                        foreach (Issue issue in aBeatmapCheck.GetIssues(aBeatmap).OrderBy(anIssue => anIssue.level).Reverse())
                        {
                            issueBag.Add(issue.WithOrigin(aBeatmapCheck));
                        }
                    }
                });

                beatmapTrack.Complete();
            });

            TryGetIssuesParallel(CheckerRegistry.GetBeatmapSetChecks(), aBeatmapSetCheck =>
            {
                if (aBeatmapSet.beatmaps.Any(aBeatmap => ((BeatmapCheckMetadata)aBeatmapSetCheck.GetMetadata()).Modes.Contains(aBeatmap.generalSettings.mode)))
                {
                    foreach (Issue issue in aBeatmapSetCheck.GetIssues(aBeatmapSet).OrderBy(anIssue => anIssue.level).Reverse())
                    {
                        issueBag.Add(issue.WithOrigin(aBeatmapSetCheck));
                    }
                }
            });

            return(issueBag.OrderByDescending(anIssue => anIssue.level).ToList());
        }
Exemplo n.º 3
0
        /// <summary> Runs the assembly of the given DLL path (can be either absolute or relative), which adds checks to the CheckerRegistry. </summary>
        public static void LoadCheckDLL(string aCheckPath)
        {
            string rootedPath = aCheckPath;

            if (!Path.IsPathRooted(aCheckPath))
            {
                rootedPath = Path.Combine(Directory.GetCurrentDirectory(), aCheckPath);
            }

            Assembly assembly = Assembly.LoadFile(rootedPath);

            foreach (Type type in assembly.GetExportedTypes())
            {
                CustomAttributeData attr =
                    type.CustomAttributes.FirstOrDefault(anAttr =>
                                                         anAttr.AttributeType.Name == typeof(CheckAttribute).Name);
                if (attr != null)
                {
                    object instance = Activator.CreateInstance(type);
                    CheckerRegistry.RegisterCheck(instance as Check);
                }
            }
        }