예제 #1
0
        public App()
        {
            WindowUtils.SetMenuAlignment();

            Assembly assembly = Assembly.GetExecutingAssembly();

            object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
            if (attributes.Length > 0)
            {
                Title = ((AssemblyTitleAttribute)attributes[0]).Title;
            }
            else
            {
                Title = Path.GetFileNameWithoutExtension(assembly.CodeBase);
            }

            attributes = assembly.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
            if (attributes.Length > 0)
            {
                Description = ((AssemblyDescriptionAttribute)attributes[0]).Description;
            }

            attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attributes.Length > 0)
            {
                Copyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
            }

            Version v = assembly.GetName().Version;

            Version = string.Format("{0}.{1}.{2}", v.Major, v.Minor, v.Build);

            attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
            if (attributes.Length > 0)
            {
                TaggedVersion = ((AssemblyProductAttribute)attributes[0]).Product.Trim();
                if (TaggedVersion.Contains(" "))
                {
                    string[] tagArr = TaggedVersion.Split(' ');
                    TaggedVersion = tagArr[tagArr.Length - 1];
                }
            }
            else
            {
                TaggedVersion = "v" + Version;
            }

            TR2RandomizerCoord.Instance.Initialise("TR2Rando", Version, TaggedVersion, new ModificationStamp
            {
                English = "Modified by TR2Rando",
                French  = "Modifié par TR2Rando",
                German  = "Geändert von TR2Rando"
            });
        }
예제 #2
0
        /// <inheritdoc/>
        public async Task <bool> PassesFilter(TaggedVersion taggedVersion)
        {
            var app  = CommandLine[0];
            var args = CommandLine
                       .Skip(1)
                       .Select(part => ReplaceTagPlaceholder(part, taggedVersion.Tag.Name))
                       .ToArray();

            var envVars = new SortedDictionary <string, string>()
            {
                ["VERLITE_PATH"]               = RepoPath,
                ["VERLITE_COMMIT"]             = taggedVersion.Tag.PointsTo.Id,
                ["VERLITE_TAG"]                = taggedVersion.Tag.Name,
                ["VERLITE_VERSION"]            = taggedVersion.Version.ToString(),
                ["VERLITE_VERSION_MAJOR"]      = taggedVersion.Version.Major.ToString(CultureInfo.InvariantCulture),
                ["VERLITE_VERSION_MINOR"]      = taggedVersion.Version.Minor.ToString(CultureInfo.InvariantCulture),
                ["VERLITE_VERSION_PATCH"]      = taggedVersion.Version.Patch.ToString(CultureInfo.InvariantCulture),
                ["VERLITE_VERSION_PRERELEASE"] = taggedVersion.Version.Prerelease ?? string.Empty,
                ["VERLITE_VERSION_BUILDMETA"]  = taggedVersion.Version.BuildMetadata ?? string.Empty,
            };

            try
            {
                var(stdout, stderr) = await Runner.Run(".", app, args, envVars);

                Log?.Verbose($"Tag {taggedVersion.Tag.Name} passed filter.");
                Log?.Verbatim($"Filter stdout:\n  {stdout.Replace("\n","\n  ")}");
                Log?.Verbatim($"Filter stderr:\n  {stderr.Replace("\n","\n  ")}");

                return(true);
            }
            catch (CommandException ex)
            {
                Log?.Verbose($"Tag {taggedVersion.Tag.Name} rejected ({ex.ExitCode}) by filter.");
                Log?.Verbatim($"Filter stdout:\n  {ex.StandardOut.Replace("\n", "\n  ")}");
                Log?.Verbatim($"Filter stderr:\n  {ex.StandardError.Replace("\n", "\n  ")}");

                return(false);
            }
        }
예제 #3
0
 async Task <bool> ITagFilter.PassesFilter(TaggedVersion taggedVersion)
 {
     return(!BlockTags.Contains(taggedVersion.Tag.Name));
 }