Beispiel #1
0
        public void Preceeding(string beforeName, string afterName)
        {
            _logs.FindByName(beforeName)
            .Add(_provenance, "putting {0} after".ToFormat(afterName));

            _logs.FindByName(afterName)
            .Add(_provenance, "putting {0} before".ToFormat(beforeName));

            _inner.Preceeding(beforeName, afterName);
        }
Beispiel #2
0
 /// <summary>
 /// Register a preceeding relationship
 /// </summary>
 /// <param name="afterName"></param>
 /// <returns></returns>
 public AssetsExpression Preceeds(string afterName)
 {
     _registration.Preceeding(_assetName, afterName);
     return(_parent);
 }
Beispiel #3
0
        public void ReadLine(string text)
        {
            if (text.Trim().IsEmpty())
            {
                return;
            }
            if (text.Trim().StartsWith("#"))
            {
                return;
            }

            var tokens = new Queue <string>(StringTokenizer.Tokenize(text.Replace(',', ' ')));

            if (tokens.Count == 1)
            {
                if (_readerAction == null)
                {
                    throw new InvalidSyntaxException("Not enough tokens in the command line");
                }

                _readerAction(tokens.First());
                return;
            }

            _lastName     = null;
            _readerAction = null;

            if (tokens.Count() < 3)
            {
                throw new InvalidSyntaxException("Not enough tokens in the command line");
            }

            var key  = tokens.Dequeue();
            var verb = tokens.Dequeue();

            if (key == "ordered")
            {
                handleOrderedSet(tokens, verb);
                return;
            }

            // TODO -- time for something more sophisticated here
            if (key == "apply")
            {
                readPolicy(tokens, verb);
                return;
            }

            if (key == "combine")
            {
                readCombination(tokens, verb);
                return;
            }

            switch (verb)
            {
            case "is":
                if (tokens.Count > 1)
                {
                    throw new InvalidSyntaxException("Only one name can appear on the right side of the 'is' verb");
                }
                _registration.Alias(tokens.Dequeue(), key);
                break;

            case "requires":
                tokens.Each(name => _registration.Dependency(key, name));
                break;

            case "extends":
                if (tokens.Count > 1)
                {
                    throw new InvalidSyntaxException("Only one name can appear on the right side of the 'extends' verb");
                }

                _registration.Extension(key, tokens.Single());
                break;

            case "includes":
                tokens.Each(name => _registration.AddToSet(key, name));
                break;

            case "preceeds":
                tokens.Each(name => _registration.Preceeding(key, name));
                break;

            default:
                string message = "'{0}' is an invalid verb".ToFormat(verb);
                throw new InvalidSyntaxException(message);
            }
        }