private static void SetupCqrsApi(IMvcBuilder mvcBuilder, CqrsApiOptions cqrsApiOptions)
        {
            mvcBuilder.ConfigureApplicationPartManager(p =>
            {
                p.FeatureProviders.Add(new CommandControllerFeatureProvider(cqrsApiOptions));
                p.FeatureProviders.Add(new QueryControllerFeatureProvider(cqrsApiOptions));
            });

            mvcBuilder.Services.AddTransient <CqrsApiControllerMetadataConvention>();
            mvcBuilder.Services.AddSingleton(cqrsApiOptions);
        }
        public static IMvcBuilder AddMvcWithCqrsApi(this IServiceCollection services, Action <MvcOptions> mvcSetupAction = null, Action <CqrsApiOptions> cqrsApiSetupAction = null)
        {
            var cqrsApiOptions = new CqrsApiOptions();

            // TODO: come up with sensible defaults if nothing is provided.
            cqrsApiSetupAction?.Invoke(cqrsApiOptions);

            var mvcBuilder = services.AddMvc(config => {
                mvcSetupAction?.Invoke(config);
                config.Conventions.Add(new CqrsApiControllerMetadataConvention(cqrsApiOptions));
            });

            SetupCqrsApi(mvcBuilder, cqrsApiOptions);

            return(mvcBuilder);
        }
 public CqrsApiControllerMetadataConvention(CqrsApiOptions cqrsApiOptions)
 {
     _cqrsApiOptions = cqrsApiOptions;
 }
Beispiel #4
0
 private CqrsApiTypeProviderBuilder(CqrsApiTypeProviderBuilder baseBuilder, IEnumerable <CQTypeMetadata> commandTypes, IEnumerable <CQTypeMetadata> queryTypes)
 {
     _cqrsApiOptions = baseBuilder._cqrsApiOptions;
     _commandTypes   = baseBuilder._commandTypes.Concat(commandTypes);
     _queryTypes     = baseBuilder._queryTypes.Concat(queryTypes);
 }
Beispiel #5
0
 internal CqrsApiTypeProviderBuilder(CqrsApiOptions cqrsApiOptions)
 {
     _cqrsApiOptions = cqrsApiOptions;
 }
Beispiel #6
0
 public QueryControllerFeatureProvider(CqrsApiOptions apiOptions)
 {
     _apiOptions = apiOptions;
 }
 public CommandControllerFeatureProvider(CqrsApiOptions cqrsApiOptions)
 {
     _cqrsApiOptions = cqrsApiOptions;
 }