Skip to content

ziyasal-archive/FluentBootstrapPolicy

Repository files navigation

FluentBootstrapPolicy

Execute pre-checks before running your application!

Build status

Define policies

public class MyAppPolicyConfiguration : AbstractPolicyConfiguration
{
    public MyAppPolicyConfiguration(IServiceLocator serviceLocator)
        : base(serviceLocator)
    {
        Check<ICurrencyProvider>(provider =>
        {
           //do sth
            return false;
        });

        Check<IStorageClient>(client =>
        {
            return client.CheckAccessControl();
        });
    }
}

Init policy context

IFluentBootstrap _policies;

ContainerBuilder builder = new ContainerBuilder();

builder.RegisterType<StorageClient>().As<IStorageClient>().SingleInstance();
builder.RegisterType<CurrencyProvider>().As<ICurrencyProvider>().SingleInstance();
builder
       .RegisterAssemblyTypes(Assembly.GetExecutingAssembly())
       .AssignableTo<AbstractPolicyConfiguration>()
       .As<AbstractPolicyConfiguration>();

var container = builder.Build();
_policies = FluentBootstrap.Instance;

_policies.Configure(ctx =>
{
    ctx.Use(new AutofacServiceLocator(container));
});

Execute policies

  _policies.Execute();

@ziλasal

About

Fluent application bootstrap policy

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages