Beispiel #1
0
        /// <summary>
        /// 为该规则增加一个参数
        /// </summary>
        /// <param name="ps"></param>
        public void AddParam(ParamState ps)
        {
            Debug.Assert(ps != null, " ParamState is null");


            if (this.ParamStates == null)
            {
                ParamStates = new Dictionary <string, ParamState>();
            }
            Debug.Assert(!ParamStates.ContainsKey(ps.ParamKey), " ParamState is Exist");

            this.ParamStates.Add(ps.ParamKey, ps);
        }
Beispiel #2
0
        /// <param name="args">Command line arguments</param>
        /// <returns>Compilation setup</returns>
        /// <exception cref="ArgumentException">
        /// A command line argument which cannot be repeated is specified more than once -or-
        /// No files are specified.
        /// </exception>
        private static RegexCompilationSettings ParseCommandLine(string[] args)
        {
            var         ret = new RegexCompilationSettings();
            bool        assemblyNameRead = false;
            bool        versionRead      = false;
            ParamStates state            = ParamStates.Files;

            foreach (string arg in args)
            {
                switch (state)
                {
                case ParamStates.Files:
                    switch (arg)
                    {
                    case "/assembly": state = ParamStates.AssemblyName; break;

                    case "/nop": ret.PostProcess = false; break;

                    case "/ver": state = ParamStates.Version; break;

                    case "/out": state = ParamStates.Out; break;

                    case "/obj": state = ParamStates.Obj; break;

                    case "/snk": state = ParamStates.Snk; break;

                    default: ret.Files.Add(arg); break;
                    }
                    break;

                case ParamStates.AssemblyName:
                    if (assemblyNameRead)
                    {
                        throw new ArgumentException("Assembly name specified twice", "/assembly");
                    }
                    assemblyNameRead = true;
                    ret.AssemblyName = arg;
                    state            = ParamStates.Files;
                    break;

                case ParamStates.Version:
                    if (versionRead)
                    {
                        throw new ArgumentException("Version specified twice", "/ver");
                    }
                    versionRead = true;
                    ret.Version = Version.Parse(arg);
                    state       = ParamStates.Files;
                    break;

                case ParamStates.Obj:
                    if (ret.ObjDir != null)
                    {
                        throw new ArgumentException("Temporary folder specified more than once", "/obj");
                    }
                    ret.ObjDir = arg;
                    state      = ParamStates.Files;
                    break;

                case ParamStates.Out:
                    if (ret.Output != null)
                    {
                        throw new ArgumentException("Output folder specified more than once", "/out");
                    }
                    ret.Output = arg;
                    state      = ParamStates.Files;
                    break;

                case ParamStates.Snk:
                    if (ret.Snk != null)
                    {
                        throw new ArgumentException("SNK path specified more than once", "/snk");
                    }
                    ret.Snk = arg;
                    state   = ParamStates.Files;
                    break;
                }
            }
            if (ret.Files.Count == 0)
            {
                throw new ArgumentException("No files specified");
            }
            return(ret);
        }