Пример #1
0
        static int Main( string[] args )
        {
            bool err = false;
            bool verbose = true;
            string reportDir = null;
            ReportFileDestination rfd = ReportFileDestination.TempFiles;
            List<string> sFileList = new List<string>();
            ValidatorParameters vp = new ValidatorParameters();

            if (args.Length == 0) {
                Usage();
                return 0;
            }

            for ( int i = 0; i < args.Length; i++ ) {
                if ( "-file" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        sFileList.Add( args[i] );
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "+table" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        vp.AddTable( args[i] );
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "-table" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        int n = vp.RemoveTableFromList( args[i] );
                        if ( 0 == n ) {
                            ErrOut( "Table \"" + args[i] + "\" not found" );
                            err = true;
                        }
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }
                }
                else if ( "-all-tables" == args[i] ) {
                    vp.SetAllTables();
                }
                else if ( "-only-tables" == args[i] ) {
                    vp.ClearTables();
                }
                else if ( "-quiet" == args[i] ) {
                    verbose = false;
                }
                else if ( "+raster-tests" == args[i] ) {
                    vp.SetRasterTesting();
                }
                else if ( "-report-dir" == args[i] ) {
                    i++;
                    if ( i < args.Length ) {
                        reportDir = args[i];
                        rfd = ReportFileDestination.FixedDir;
                        // Try writing to the directory to see if it works.
                        using (FileStream fs = File.Create(
                                                           Path.Combine(
                                                                        reportDir,
                                                                        Path.GetRandomFileName()
                                                                        ),
                                                           1, // bufferSize
                                                           FileOptions.DeleteOnClose)
                               )
                        { };
                        // exception should throw & abort on failure
                    } else {
                        ErrOut( "Argument required for \"" + args[i-1] + "\"" );
                        err = true;
                    }

                }
                else if ( "-report-in-font-dir" == args[i] ) {
                    rfd = ReportFileDestination.SameDirAsFont;
                }
                else {
                    ErrOut( "Unknown argument: \"" + args[i] + "\"" );
                    err = true;
                }
            }
            if ( err ) {
                Usage();
                return 1;
            }

            CmdLineInterface cmd = new
                CmdLineInterface( vp, sFileList.ToArray(), rfd, false,
                                  reportDir , verbose);
            return cmd.DoIt();
        }