Exemple #1
0
        public ObjModel Run(StreamReader reader = null)
        {
            if (reader != null)
            {
                GetLine = reader.ReadLine;
            }
            ObjModel model = new ObjModel();
            string   line;

            while (null != (line = GetLine()))
            {
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }
                if (line[0] == '#')
                {
                    continue;
                }
                var           split  = line.Split(" ");
                List <string> tokens = new List <string>();
                foreach (var str in split)
                {
                    if (!string.IsNullOrWhiteSpace(str))
                    {
                        tokens.Add(str);
                    }
                }

                if (tokens.Count > 0)
                {
                    string        name  = tokens[0];
                    List <string> param = tokens.GetRange(1, tokens.Count - 1);
                    IObjCommand   cmd   = null;
                    if (commands.TryGetValue(name, out cmd))
                    {
                        cmd.Execute(param, model);
                    }
                }
            }
            return(model);
        }
Exemple #2
0
 public void AddCommand(string name, IObjCommand command)
 {
     parser.commands.Add(name, command);
 }