예제 #1
0
        public ArgumentList(IEnumerable <string> items)
        {
            Arguments = new OrderedDictionary <string, IArgument> ();

            foreach (var item in items)
            {
                int    integerValue;
                string argumentName;
                string argumentValue;

                if (item.StartsWith(@"""") || Int32.TryParse(item, out integerValue))
                {
                    argumentName  = GetNextArgumentName();
                    argumentValue = item;
                }
                else
                {
                    var parts = item.Split('=');
                    if (parts.Length > 1)
                    {
                        argumentName  = parts [0];
                        argumentValue = String.Join("=", parts.Skip(1));
                    }
                    else
                    {
                        argumentName  = GetNextArgumentName();
                        argumentValue = item;
                    }
                }

                Arguments.Add(argumentName, ArgumentFactory.CreateArgument(argumentValue, true));
            }
        }
예제 #2
0
        public NestedVariableArgument(string name, bool allowContextRecursion)
        {
            string [] parts = name.Split(new [] { '.' }, 2);

            /*
             * if (allowContextRecursion)
             * {
             *  MainArgument = new RecursiveVariableArgument (parts [0]);
             * } else
             * {
             *  MainArgument = new StrictVariableArgument (parts[0]);
             * }
             */
            MainArgument   = ArgumentFactory.CreateArgument(parts [0], allowContextRecursion);
            NestedArgument = ArgumentFactory.CreateArgument(parts [1], false);

            if (NestedArgument != null)
            {
                // Optimize indexed access.
                if (NestedArgument is IntegerArgument)
                {
                    MainArgument   = new IndexedVariableArgument(MainArgument, (NestedArgument as IntegerArgument).Data);
                    NestedArgument = null;
                }
                else if (NestedArgument is NestedVariableArgument && (NestedArgument as NestedVariableArgument).MainArgument is IntegerArgument)
                {
                    MainArgument   = new IndexedVariableArgument(MainArgument, ((NestedArgument as NestedVariableArgument).MainArgument as IntegerArgument).Data);
                    NestedArgument = (NestedArgument as NestedVariableArgument).NestedArgument;
                }
            }
        }
예제 #3
0
 public ParentVariableArgument(string name)
 {
     Argument = ArgumentFactory.CreateArgument(name, false);
 }