Пример #1
0
        internal static Options ParseArguments(string[] args)
        {
            Mode    mode    = Mode.NotSpecified;
            Options options = null;

            if (args.Length > 0)
            {
                ArgumentDictionary arguments = CommandParser.ParseCommand(args, switches);

                if (arguments.ContainsArgument(Cmd.Install))
                {
                    mode = Mode.Install;
                }

                if (arguments.ContainsArgument(Cmd.Uninstall))
                {
                    if (mode != Mode.NotSpecified)
                    {
                        throw Tool.CreateException(SR.GetString(SR.MultipleModeArguments), null);
                    }

                    mode = Mode.Uninstall;
                }

                if (arguments.ContainsArgument(Cmd.List))
                {
                    if (mode != Mode.NotSpecified)
                    {
                        throw Tool.CreateException(SR.GetString(SR.MultipleModeArguments), null);
                    }

                    mode = Mode.List;
                }
                options = new Options(mode, arguments);
            }
            else
            {
                return(new Options(mode, null));
            }

            if (!options.Help && (mode == Mode.NotSpecified))
            {
                throw Tool.CreateException(SR.GetString(SR.ModeArgumentMissing), null);
            }

            return(options);
        }
Пример #2
0
        Options(Mode mode, ArgumentDictionary arguments)
        {
            if (arguments == null)
            {
                help = true;
                return;
            }
            this.mode = mode;
            // Application
            if (arguments.ContainsArgument(Cmd.Application))
            {
                this.application = arguments.GetArgument(Cmd.Application);
            }

            // Help
            this.help = arguments.ContainsArgument(Cmd.Help);

            // Hosting
            this.hosting = Hosting.NotSpecified;

            if (arguments.ContainsArgument(Cmd.Hosting))
            {
                string argValue = arguments.GetArgument(Cmd.Hosting);
                if (string.Equals(argValue, Enum.GetName(typeof(Hosting), Hosting.Complus), StringComparison.OrdinalIgnoreCase))
                {
                    this.hosting = Hosting.Complus;
                }
                else if (string.Equals(argValue, Enum.GetName(typeof(Hosting), Hosting.Was), StringComparison.OrdinalIgnoreCase))
                {
                    if (WasAdminWrapper.IsIISInstalled())
                    {
                        this.hosting = Hosting.Was;
                    }
                    else
                    {
                        throw Tool.CreateException(SR.GetString(SR.IISNotInstalled, argValue), null);
                    }
                }
                else
                {
                    throw Tool.CreateException(SR.GetString(SR.UnknownHostingSpecified, argValue), null);
                }
            }

            this.mex = arguments.ContainsArgument(Cmd.MetaData);

            // Interface
            this.components    = null;
            this.allComponents = false;
            if (arguments.ContainsArgument(Cmd.Contract))
            {
                IList <string> argValues = arguments.GetArguments(Cmd.Contract);
                ParseInterfaces(argValues);
            }



            // NoLogo
            this.noLogo = arguments.ContainsArgument(Cmd.NoLogo);
            if (this.noLogo && arguments.Count == 1)
            {
                this.help = true;
            }

            // Verbose
            this.verbose = arguments.ContainsArgument(Cmd.Verbose);

            // WebDirectory
            if (arguments.ContainsArgument(Cmd.WebDirectory))
            {
                this.webDirectory = arguments.GetArgument(Cmd.WebDirectory);
            }

            // WebServer
            if (arguments.ContainsArgument(Cmd.WebServer))
            {
                this.webServer = arguments.GetArgument(Cmd.WebServer);
            }

            this.showGuids = arguments.ContainsArgument(Cmd.ID);

            this.allowReferences = arguments.ContainsArgument(Cmd.AllowReferences);
        }