Пример #1
0
        private static bool ValidateConfiguration(ManifestConfiguration config)
        {
            if (string.IsNullOrEmpty(config.RootDirectory) ||
                string.IsNullOrEmpty(config.ManifestFilePath))
            {
                return false;
            }

            if (config.CheckManifest && string.IsNullOrEmpty(config.ReportFilePath))
            {
                return false;
            }

            if (config.BuildManifest == true && config.CheckManifest == true)
            {
                return false;
            }

            if (config.BuildManifest == false && config.CheckManifest == false)
            {
                return false;
            }

            return true;
        }
Пример #2
0
        private static ManifestConfiguration ParseArguments(string[] args)
        {
            // Remove any dash prefix from arguments.
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].StartsWith("-"))
                {
                    string currentArg = args[i];
                    for (int j = 0; j < currentArg.Length; j++)
                    {
                        if (currentArg.Substring(j, 1) != "-")
                        {
                            args[i] = currentArg.Substring(j);
                            break;
                        }
                    }
                }
            }

            string rootDirectory = null;
            string manifestFilePath = null;
            string reportFilePath = null;
            bool build = false;
            bool check = false;

            if (args.Contains(DIRECTORY_ARG))
            {
                int directoryArgIndex = Array.IndexOf(args, DIRECTORY_ARG);

                if (directoryArgIndex != (args.Length - 1))
                {
                    rootDirectory = args[directoryArgIndex + 1];
                }
            }

            if (args.Contains(MANIFEST_FILE_ARG))
            {
                int fileArgIndex = Array.IndexOf(args, MANIFEST_FILE_ARG);

                if (fileArgIndex != (args.Length - 1))
                {
                    manifestFilePath = args[fileArgIndex + 1];
                }
            }

            if (args.Contains(REPORT_FILE_ARG))
            {
                int fileArgIndex = Array.IndexOf(args, REPORT_FILE_ARG);

                if (fileArgIndex != (args.Length - 1))
                {
                    reportFilePath = args[fileArgIndex + 1];
                }
            }

            if (args.Contains(BUILD_ARG))
            {
                build = true;
            }

            if (args.Contains(CHECK_ARG))
            {
                check = true;
            }

            ManifestConfiguration config = new ManifestConfiguration(rootDirectory, manifestFilePath, build, check, reportFilePath);

            return config;
        }