aboutsummaryrefslogtreecommitdiff
path: root/src/tools/heat/IIsHeatExtension.cs
blob: be99837074bb131fa61babe2a3b71b6287cd269d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

namespace WixToolset.Harvesters
{
    using WixToolset.Harvesters.Data;
    using WixToolset.Harvesters.Extensibility;

    /// <summary>
    /// An IIS harvesting extension for the WiX Toolset Harvester application.
    /// </summary>
    public sealed class IIsHeatExtension : BaseHeatExtension
    {
        /// <summary>
        /// Gets the supported command line types for this extension.
        /// </summary>
        /// <value>The supported command line types for this extension.</value>
        public override HeatCommandLineOption[] CommandLineTypes
        {
            get
            {
                return new HeatCommandLineOption[]
                {
                    new HeatCommandLineOption("website", "harvest an IIS web site"),
                };
            }
        }

        /// <summary>
        /// Parse the command line options for this extension.
        /// </summary>
        /// <param name="type">The active harvester type.</param>
        /// <param name="args">The option arguments.</param>
        public override void ParseOptions(string type, string[] args)
        {
            bool active = false;
            IHarvesterExtension harvesterExtension = null;
            IIsHarvesterMutator iisHarvesterMutator = new IIsHarvesterMutator();

            // select the harvester
            switch (type)
            {
                case "website":
                    harvesterExtension = new IIsWebSiteHarvester();
                    active = true;
                    break;
            }

            // set default settings
            iisHarvesterMutator.SetUniqueIdentifiers = true;

            // parse the options
            foreach (string arg in args)
            {
                if (null == arg || 0 == arg.Length) // skip blank arguments
                {
                    continue;
                }

                if ('-' == arg[0] || '/' == arg[0])
                {
                    string parameter = arg.Substring(1);

                    if ("suid" == parameter)
                    {
                        iisHarvesterMutator.SetUniqueIdentifiers = false;
                    }
                }
            }

            // set the appropriate harvester extension
            if (active)
            {
                this.Core.Harvester.Extension = harvesterExtension;
                this.Core.Mutator.AddExtension(iisHarvesterMutator);
                this.Core.Mutator.AddExtension(new IIsFinalizeHarvesterMutator());
                this.Core.Mutator.AddExtension(new UtilFinalizeHarvesterMutator());
            }
        }
    }
}