public void AttemptToAttachViewToAction(ViewBag bag, ActionCall call, IConfigurationObserver observer) { foreach (var filter in _filters) { var viewTokens = filter.Apply(call, bag); var count = viewTokens.Count(); observer.RecordCallStatus(call, "View filter '{0}' found {1} view token{2}".ToFormat( filter.GetType().Name, count, (count != 1) ? "s" : "" )); if( count > 0 ) { viewTokens.Each(t => observer.RecordCallStatus(call, "Found view token: {0}".ToFormat(t))); } // if the filter returned more than one, consider it "failed", ignore it, and move on to the next if (count != 1) continue; var token = viewTokens.First(); observer.RecordCallStatus(call, "Selected view token: {0}".ToFormat(token)); call.AddToEnd(token.ToBehavioralNode()); break; } }
public virtual void Attach(IViewProfile viewProfile, ViewBag bag, ActionCall action) { // No duplicate views! var outputNode = action.ParentChain().Output; if (outputNode.HasView(viewProfile.ConditionType)) return; var log = new ViewAttachmentLog(viewProfile); action.Trace(log); foreach (var filter in _filters) { var viewTokens = filter.Apply(action, bag); var count = viewTokens.Count(); if (count > 0) { log.FoundViews(filter, viewTokens.Select(x => x.Resolve())); } if (count != 1) continue; var token = viewTokens.Single().Resolve(); outputNode.AddView(token, viewProfile.ConditionType); break; } }
public void Configure(ViewBag bag, BehaviorGraph graph) { graph.Behaviors .Select(x => x.FirstCall()) .Where(x => x != null) .Each(a => AttemptToAttachViewToAction(bag, a, graph.Observer)); }
IEnumerable<BehaviorChain> FindChainsWithoutViews(BehaviorGraph graph, ViewBag bag) { return from b in graph.Behaviors where b.ActionOutputType() != null && b.ActionOutputType().Closes(typeof(AwesomeCreateModel<>)) let output = b.ActionOutputType() where !bag.ViewsFor(output).Any() select b; }
public void ImportInto(IChainImporter graph, ViewBag views) { // TODO -- will want this to suck in the configuration log business somehow Registry.Compile(); var childGraph = Registry.Configuration.BuildForImport(views); graph.Import(childGraph, b => { b.PrependToUrl(Prefix); b.Origin = Registry.Name; }); }
public void Configure(BehaviorGraph graph) { var views = new List <IViewToken>(); foreach (var facility in _facilities) { views.AddRange(facility.FindViews(_types, graph)); } var bag = new ViewBag(views); _conventions.Each(c => c.Configure(bag, graph)); }
public void Configure(ViewBag bag, BehaviorGraph graph) { FindChainsWithoutViews(graph, bag).Each(b => { var output = b.ActionOutputType(); var entityType = output.GetGenericArguments()[0]; var handlerType = typeof (AwesomeCreateHandler<>).MakeGenericType(entityType); var method = handlerType.GetMethod("DaisyChain"); b.AddToEnd(new ActionCall(handlerType,method)); var token = bag.ViewsFor(typeof (AwesomeEditModel)).First(); b.AddToEnd(token.ToBehavioralNode()); }); }
public void SetUp() { token = new FakeViewToken { ViewName = "AAction", Namespace = GetType().Namespace, ViewType = typeof(AAction), ViewModel = typeof (ViewModel1) }; var views = new List<IViewToken> { token }; bag = new ViewBag(views); filter = new ActionWithSameNameAndFolderAsViewReturnsViewModelType(); }
internal IEnumerable <ProfileViewBag> Profiles(ViewBag views) { if (_profiles.Any()) { foreach (var profile in _profiles) { yield return(new ProfileViewBag(profile, views)); } Func <IViewToken, bool> defaultFilter = x => !_defaultExcludes.Any(test => test(x)); var defaultProfile = new ViewProfile(Always.Flyweight, defaultFilter, x => x.Name()); yield return(new ProfileViewBag(defaultProfile, views)); } else { yield return(new ProfileViewBag(new DefaultProfile(), views)); } }
public void Configure(BehaviorGraph graph) { _types.ShouldScanAssemblies = true; var views = new List <IViewToken>(); foreach (var facility in _facilities) { views.AddRange(facility.FindViews(_types, graph)); } //= _facilities.SelectMany(x => x.FindViews(_types)); var bag = new ViewBag(views); graph.Behaviors .Select(x => x.FirstCall()) .Where(x => x != null) .Each(a => AttemptToAttachViewToAction(bag, a, graph.Observer)); }
public void Attach(IViewProfile viewProfile, ViewBag bag, ActionCall action) { // No duplicate views! var outputNode = action.ParentChain().Output; if (outputNode.HasView(viewProfile.Condition)) return; foreach (var filter in _policy.Filters()) { var viewTokens = filter.Apply(action, bag); var count = viewTokens.Count(); if (count != 1) continue; var token = viewTokens.Single().Resolve(); _attached.Add(token); outputNode.AddView(token, viewProfile.Condition); break; } }
public ViewBag Filter(ViewBag bag) { return bag; }
public void Configure(ViewBag bag, BehaviorGraph graph) { Invocations++; }
public ViewAttachmentWorker(ViewBag views, ViewAttachmentPolicy policy) { _views = views; _policy = policy; }
public virtual void Attach(ViewAttachmentPolicy policy, IViewProfile viewProfile, ViewBag bag, ActionCall action) { // No duplicate views! var outputNode = action.ParentChain().Output; if (outputNode.HasView(viewProfile.ConditionType)) { return; } var log = new ViewAttachmentLog(viewProfile); action.Trace(log); foreach (var filter in policy.Filters()) { var viewTokens = filter.Apply(action, bag); var count = viewTokens.Count(); if (count > 0) { log.FoundViews(filter, viewTokens.Select(x => x.Resolve())); } if (count != 1) { continue; } var token = viewTokens.Single().Resolve(); outputNode.AddView(token, viewProfile.ConditionType); break; } }
public IEnumerable <IViewToken> Apply(ActionCall call, ViewBag views) { return(views.ViewsFor(call.OutputType()).Where(view => view.Name == call.Method.Name && view.Folder == call.HandlerType.Namespace)); }
public ViewBag Filter(ViewBag bag) { return(bag); }
public void Configure(BehaviorGraph graph) { _types.ShouldScanAssemblies = true; var views = new List<IViewToken>(); foreach (var facility in _facilities) { views.AddRange(facility.FindViews(_types, graph)); } //= _facilities.SelectMany(x => x.FindViews(_types)); var bag = new ViewBag(views); graph.Behaviors .Select(x => x.FirstCall()) .Where(x => x != null) .Each(a => AttemptToAttachViewToAction(bag, a, graph.Observer)); }
public ProfileViewBag(IViewProfile profile, ViewBag views) { Profile = profile; Views = profile.Filter(views); }
public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views) { return views.ViewsFor(call.OutputType()); }
public ViewBag Filter(ViewBag bag) { var views = bag.Views.Where(_filter).Select(x => new ProfileViewToken(x, _getName(x))); return(new ViewBag(views)); }
public IEnumerable <IViewToken> Apply(ActionCall call, ViewBag views) { return(views.ViewsFor(call.OutputType())); }
public IEnumerable<IViewToken> Apply(ActionCall call, ViewBag views) { return views.ViewsFor(call.OutputType()).Where(view => view.Name == call.Method.Name && view.Folder == call.HandlerType.Namespace); }
public ViewBag Filter(ViewBag bag) { var views = bag.Views.Where(_filter).Select(x => new ProfileViewToken(x, _getName(x))); return new ViewBag(views); }
public ViewAttachmentWorker(ViewBag views, ViewAttachmentPolicy policy) { _views = views; _policy = policy; }