/// <summary> /// Used internally to build the fixture model that the Storyteller client /// uses to render the screens /// </summary> /// <param name="conversions"></param> /// <returns></returns> public virtual FixtureModel Compile(CellHandling conversions) { GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance).Where(methodFromThis).Where(x => !x.HasAttribute <HiddenAttribute>()).Each(method => { var grammarKey = method.GetKey(); if (_grammars.Has(grammarKey)) { return; } var grammar = GrammarBuilder.BuildGrammar(method, this); grammar.Key = grammarKey; this[grammarKey] = grammar; }); var grammars = new List <GrammarModel>(); _grammars.Each((key, grammar) => { var model = grammar.Compile(this, conversions); model.key = key; model.IsHidden = grammar.IsHidden; grammars.Add(model); }); return(new FixtureModel(Key) { title = Title ?? Key.SplitCamelCase(), grammars = grammars.Where(x => !x.IsHidden).ToArray(), implementation = GetType().FullName }); }
public static Type TypeForJson(string json) { var token = JToken.Parse(json); var type = token.Value <string>("type"); return((!type.IsEmpty() && _messageTypes.Has(type)) ?_messageTypes[type] : null); }
public TypeConfig For(string typeName) { var exists = _typeConfigurations.Has(typeName); var typeConfig = _typeConfigurations[typeName]; if (!exists) { _forAllTypesConfigurationDelegates.Apply(a => a.Invoke(typeConfig)); } return(typeConfig); }
public T TryRetrieve <T>(string key) { if (!_byName.Has(typeof(T))) { return(default(T)); } var cache = _byName[typeof(T)]; return(cache.Has(key) ? cache[key].As <T>() : default(T)); }
public CommandRun BuildRun(IEnumerable <string> args) { if (!args.Any()) { if (DefaultCommand == null) { return(HelpRun(new Queue <string>())); } } args = ArgPreprocessor.Process(args); var queue = new Queue <string>(args); if (queue.Count == 0 && DefaultCommand != null) { return(buildRun(queue, CommandNameFor(DefaultCommand))); } var firstArg = queue.Peek().ToLowerInvariant(); if (firstArg == "dump-usages") { queue.Dequeue(); return(dumpUsagesRun(queue)); } if (_helpCommands.Contains(firstArg)) { queue.Dequeue(); return(HelpRun(queue)); } if (_commandTypes.Has(firstArg)) { queue.Dequeue(); return(buildRun(queue, firstArg)); } if (DefaultCommand != null) { return(buildRun(queue, CommandNameFor(DefaultCommand))); } else { return(InvalidCommandRun(firstArg)); } }
public TypeConfig For(string typeName) { var exists = _typeConfigurations.Has(typeName); var typeConfig = _typeConfigurations[typeName]; if (!exists) { foreach (var a in _forAllTypesConfigurationDelegates) { a.Invoke(typeConfig); } } return(typeConfig); }
public Specification RemoveSpec(string id) { if (!Specifications.Has(id)) { return(null); } var old = Specifications[id]; var suite = Suites[old.SuitePath()]; suite.RemoveSpec(old); Specifications.Remove(id); return(old); }
public Route RouteFor(Type handlerType, MethodInfo method) { if (!_routesPerHandler.Has(handlerType)) { throw new UrlResolutionException($"There are no matching routes for handler {handlerType.FullName}"); } var routes = _routesPerHandler[handlerType]; if (!routes.Has(method.Name)) { throw new UrlResolutionException($"No route matches the method {handlerType.FullName}.{method.Name}()"); } var route = routes[method.Name]; return(route); }
private Route RouteByName(string routeName) { return(_routesPerName.Has(routeName) ? _routesPerName[routeName] : null); }
public IReadOnlyList <Type> ForwardingTypesTo(Type handledType) { return(_forwarders.Has(handledType) ? _forwarders[handledType] : new List <Type>()); }
public bool Has(Type type) { return(_convertors.Has(type) || providers().Any(x => x.ConverterFor(type) != null)); }
bool IQueueIndexer.Has(string queueName) { return _queues.Has(queueName); }
public Topic FindTopicByUrl(string url) { return(_topicByUrl.Has(url) ? _topicByUrl[url] : null); }
public void get_all_keys() { cache.Fill(Key, 42); cache.Count().ShouldBe(1); cache.Has(Key).ShouldBeTrue(); }
public T TryRetrieve <T>() { return(_byType.Has(typeof(T)) ? _byType[typeof(T)].As <T>() : default(T)); }