public static FubuMVC.Swank.Specification.Specification GetSpec(Action <Swank> configure = null) { var graph = Behavior.BuildGraph().AddActionsInThisNamespace(); var moduleConvention = new ModuleConvention(new MarkerConvention <ModuleDescription>()); var resourceConvention = new ResourceConvention( new MarkerConvention <ResourceDescription>(), new BehaviorSource(graph, Swank.CreateConfig(x => x.AppliesToThisAssembly().Where(ActionFilter)))); var configuration = Swank.CreateConfig(x => { x.AppliesToThisAssembly().Where(ActionFilter).WithEnumValueTypeOf(EnumValue.AsString); if (configure != null) { configure(x); } }); var specBuilder = new FubuMVC.Swank.Specification.SpecificationService(configuration, new BehaviorSource(graph, configuration), new TypeDescriptorCache(), moduleConvention, resourceConvention, new EndpointConvention(), new MemberConvention(), new OptionConvention(), new StatusCodeConvention(), new HeaderConvention(), new TypeConvention(), new MergeService()); return(specBuilder.Generate()); }
public GetHandler( SpecificationService specificationService, Configuration configuration) { _specification.UseFactory(specificationService.Generate); _configuration = configuration; }
public static FubuMVC.Swank.Specification.Specification GetSpec(Action<Swank> configure = null) { var graph = Behavior.BuildGraph().AddActionsInThisNamespace(); var moduleConvention = new ModuleConvention(new MarkerConvention<ModuleDescription>()); var resourceConvention = new ResourceConvention( new MarkerConvention<ResourceDescription>(), new BehaviorSource(graph, Swank.CreateConfig(x => x.AppliesToThisAssembly().Where(ActionFilter)))); var configuration = Swank.CreateConfig(x => { x.AppliesToThisAssembly().Where(ActionFilter).WithEnumFormat(EnumFormat.AsString); if (configure != null) configure(x); }); var typeCache = new TypeDescriptorCache(); var memberConvention = new MemberConvention(); var optionFactory = new OptionFactory(configuration, new EnumConvention(), new OptionConvention()); var specBuilder = new FubuMVC.Swank.Specification.SpecificationService( configuration, new BehaviorSource(graph, configuration), typeCache, moduleConvention, resourceConvention, new EndpointConvention(), memberConvention, new StatusCodeConvention(), new HeaderConvention(), new MimeTypeConvention(), new TypeGraphFactory( configuration, typeCache, new TypeConvention(configuration), memberConvention, optionFactory), new BodyDescriptionFactory(configuration), new OptionFactory(configuration, new EnumConvention(), new OptionConvention())); return specBuilder.Generate(); }
public Specification Merge(Specification specification1, Specification specification2) { Func <string, IEnumerable <Resource>, Resource> mergeResources = (resourceKey, resources) => new Resource { Name = resources.Select(y => y.Name).FirstOrDefault(), Comments = resources.Select(y => y.Comments).FirstOrDefault(), Endpoints = resources.SelectMany(x => x.Endpoints).GroupBy( x => x.Name ?? ("{0}:{1}".ToFormat(x.Method, x.Url)), x => x, (endpointKey, endpoints) => endpoints.First()).OrderBy(x => x.Url.Split('?').First()) .ThenBy(x => SpecificationService.HttpVerbRank(x.Method)).ToList() }; return(new Specification { Name = specification1.Name ?? specification2.Name, Comments = specification1.Comments ?? specification2.Comments, Types = specification1.Types.OuterJoin(specification2.Types, x => x.Id ?? x.Name, (key, types) => new Type { Id = types.Select(y => y.Id).FirstOrDefault(), Name = types.Select(y => y.Name).FirstOrDefault(), Comments = types.Select(y => y.Comments).FirstOrDefault(), Members = types.Select(y => y.Members).FirstOrDefault(y => y != null && y.Any()) }) .OrderBy(x => x.Name).ToList(), Modules = specification1.Modules.OuterJoin(specification2.Modules, x => x.Name, (moduleKey, modules) => new Module { Name = modules.Select(y => y.Name).FirstOrDefault(), Comments = modules.Select(y => y.Comments).FirstOrDefault(), Resources = modules.SelectMany(x => x.Resources) .GroupBy(x => x.Name, x => x, mergeResources) .OrderBy(x => x.Name).ToList() }).OrderBy(x => x.Name).ToList(), Resources = specification1.Resources .OuterJoin(specification2.Resources, x => x.Name, mergeResources) .OrderBy(x => x.Name).ToList() }); }
public DataGetHandler( SpecificationService specificationService) { _specification.UseFactory(specificationService.Generate); }