コード例 #1
0
        // Internal for testing
        internal void AddRecipePackageAndSetTheme()
        {
            if (Recipe == null && !string.IsNullOrEmpty(RecipeName))
            {
                KnownRecipe knownRecipe;
                if (KnownRecipe.Values.TryGetValue(RecipeName, out knownRecipe))
                {
                    Trace.Verbose($"Recipe {RecipeName} was in the lookup of known recipes");

                    // Make sure we're not ignoring packages
                    if (!IgnoreKnownRecipePackages)
                    {
                        // Add the package, but only if it wasn't added manually
                        if (!string.IsNullOrEmpty(knownRecipe.PackageId) && !PackageInstaller.ContainsPackage(knownRecipe.PackageId))
                        {
                            PackageInstaller.AddPackage(knownRecipe.PackageId);
                        }
                    }
                    else
                    {
                        Trace.Verbose("Ignoring known recipe packages");
                    }

                    // Set the theme if we don't already have one
                    if (string.IsNullOrEmpty(Theme))
                    {
                        Theme = knownRecipe.DefaultTheme;
                    }
                }
                else
                {
                    Trace.Verbose($"Recipe {RecipeName} is not in the lookup of known recipes");
                }
            }
        }
コード例 #2
0
ファイル: Configurator.cs プロジェクト: tbolon/Wyam
        // Internal for testing
        internal void AddThemePackagesAndPath()
        {
            string inputPath = Theme;

            if (!string.IsNullOrEmpty(Theme))
            {
                KnownTheme knownTheme;
                if (KnownTheme.Values.TryGetValue(Theme, out knownTheme))
                {
                    Trace.Verbose($"Theme {Theme} was in the lookup of known themes");
                    inputPath = knownTheme.InputPath;

                    // Do a sanity check against the recipe (but only if we didn't explicitly specify one)
                    if (Recipe == null && !string.IsNullOrEmpty(RecipeName) && !string.IsNullOrEmpty(knownTheme.Recipe) &&
                        !string.Equals(RecipeName, knownTheme.Recipe, StringComparison.OrdinalIgnoreCase))
                    {
                        Trace.Warning($"Theme {Theme} is designed for recipe {knownTheme.Recipe} but is being used with recipe {RecipeName}, results may be unexpected");
                    }

                    // Make sure we're not ignoring theme packages
                    if (!IgnoreKnownThemePackages)
                    {
                        // Add the package, but only if it wasn't added manually
                        if (!string.IsNullOrEmpty(knownTheme.PackageId) && !PackageInstaller.ContainsPackage(knownTheme.PackageId))
                        {
                            PackageInstaller.AddPackage(knownTheme.PackageId, versionRange: $"[{Engine.Version}]", allowPrereleaseVersions: true);
                        }
                    }
                    else
                    {
                        Trace.Verbose("Ignoring known theme packages");
                    }
                }
                else
                {
                    Trace.Verbose($"Theme {Theme} is not in the lookup of known themes, assuming it's an input path");
                }
            }

            // Insert the theme path
            if (!string.IsNullOrEmpty(inputPath))
            {
                _engine.FileSystem.InputPaths.Insert(0, new DirectoryPath(inputPath));
            }
        }