public void AddToSet(string setName, string name) { _logs.FindByName(setName) .Add(_provenance, "Add {0} to the set".ToFormat(name)); _logs.FindByName(name) .Add(_provenance, "Added to set {0}".ToFormat(setName)); _inner.AddToSet(setName, name); }
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); } }