Пример #1
0
        /// <summary>
        /// Initialises the Settings using the supplied arguments.
        /// </summary>
        /// <param name="startArgs">The array of arguments to use for intialisation. See Settings for required args and format.</param>
        /// <returns>True if initialisation completed successfully. Otherwise false.</returns>
        private static bool InitSettings(string[] startArgs)
        {
            bool OK = false;
            try
            {
                TheSettings = new Settings(startArgs);
                TheSettings[Settings.ToolsPathKey] = System.IO.Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);

                //Immediately check that they are valid
                if (!TheSettings.CheckIfArgsValid())
                {
                    throw new ArgumentException("Arguments invalid! Use \"help=on\" for help.");
                }
                //If the arguments are valid, check that all the required ones are there.
                else if (!TheSettings.CheckForRequiredArgs())
                {
                    throw new ArgumentException("Arguments missing! Use \"help=on\" for help.");
                }
                OK = true;
            }
            catch(Exception ex)
            {
                if (ExecutingUnderMSBuild)
                {
                    MSBuild_OutputError(ex);
                }
                else
                {
                    OutputError(ex);
                }
                OK = false;
            }
            return OK;
        }