コード例 #1
0
        public int Execute(TextWriter error, params string[] args)
        {
            ProxyGeneratorOptions generatorOptions = new ProxyGeneratorOptions();

            if (Parser.ParseHelp(args))
            {
                Parser.ParseArguments(args, generatorOptions);
            }
            else if (Parser.ParseArguments(args, generatorOptions) == false)
            {
                error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType()));
                return(Error.InvalidArguments);
            }

            if (_proxyGenerator == null)
            {
                try
                {
                    _proxyGenerator = CreateProxyGenerator(generatorOptions.Generator);
                }
                catch (Exception exc)
                {
                    error.WriteLine(exc.Message);
                    return(Error.CreateProxyGenerator);
                }
            }

            generatorOptions = _proxyGenerator.GetOptions();
            if (generatorOptions == null)
            {
                error.WriteLine("{0}.GetOptions() returned null.  Please use a different Generator.", _proxyGenerator.GetType().FullName);
                return(Error.InvalidGenerator);
            }

            if (Parser.ParseHelp(args))
            {
                error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType()));
                return(Error.None);
            }
            if (Parser.ParseArguments(args, generatorOptions) == false)
            {
                error.WriteLine(Parser.ArgumentsUsage(generatorOptions.GetType()));
                return(Error.InvalidArguments);
            }

            try
            {
                _proxyGenerator.Generate(generatorOptions);
            }
            catch (Exception exc)
            {
                error.WriteLine(exc.Message);
                error.WriteLine(exc.StackTrace);
                return(Error.Unknown);
            }

            return(Error.None);
        }
コード例 #2
0
        public void SetUp()
        {
            _error = new StringWriter();
            _mocks = new MockRepository();

            _generator = _mocks.DynamicMock<IProxyGenerator>();
            SetupResult.For(_generator.GetOptions())
                .Return(new ProxyGeneratorOptions());

            _program = new Program();
            _program.ProxyGenerator = _generator;
        }
コード例 #3
0
        public void SetUp()
        {
            _error = new StringWriter();
            _mocks = new MockRepository();

            _generator = _mocks.DynamicMock <IProxyGenerator>();
            SetupResult.For(_generator.GetOptions())
            .Return(new ProxyGeneratorOptions());

            _program = new Program();
            _program.ProxyGenerator = _generator;
        }