GithubHelp home page GithubHelp logo

diceioc's People

Contributors

christav avatar

Stargazers

Jose Bueno avatar Christopher Bennage avatar

Watchers

Christopher Bennage avatar  avatar

diceioc's Issues

Rethink naming scheme

Quick, what's the difference between LifetimeContainer and LifetimeScope? Registrar and Catalog?

Come up with a better set of names for stuff, then apply them consistently.

Disposing container should dispose current scope

Saves an extra line, so instead of:

using(var s = new LifetimeScope()) {
    var c = container.InScope(s);
    c.Resolve<IFoo>();
    /// do stuff
}

We could instead do:

using(var c = container.InScope(new LifetimeScope()) {
    c.Resolve<IFoo>();
    /// do stuff
}

Also consider adding InNewScope method to simplify the above using line a little more.

Add Module concept

Provide a class users can implement that will register stuff in the container when new'ed up - allows for easy modularization/reuse of configuration.

Add ResolveOptional method

TryResolve follows the usual TryAction pattern, returning a bool and using an out parameter. Which makes it impossible to call from an expression tree, which means we can't use TryResolve to resolve an optional parameter in a registered function.

Add an ResolveOptional method that will return default(T) if the type in question is not registered. This lets us support optional dependencies easily.

Plug extra disposable objects into LifetimeScope

Provide a way to add additional disposable objects to lifetime scope at resolve time that will get disposed with the scope. Example usage: pooled lifetime, where when the scope goes away the objects get released back into the pool.

Autowiring catalog

I should be able to do:

catalog.Register<IFoo, Foo>();

and the catalog should figure out which constructor to call based on what else is registered.

Better, more consistent exceptions

Define what our exceptions should be under what circumstances, and apply the design across the codebase.

Should we have a base exception? Or a couple? ConfigException/ResolveException, maybe?

Support Buildup operation

Support setting properties through the container on an object that's already been created by some other means.

Add named scopes to container

Would let us do something like this:

catalog.Register<IFoo>(c => new Foo(), Scope.Lifetime("perrequest"));
catalog.Register<IBar>(c => new Bar(c.Resolve<IFoo>()), Scope.Lifetime);

And let us have multiple instances of lifetime scopes at resolve time.

Come up with better catalog/registrar composition scheme

Catalog code is a tangled mess right now. Come up with cleaner design that allows easier composition of different catalog implementations.

Figure out a way to cleanly combine the various kinds of registrations into a single coherent registration API for end users that vectors down to the various catalog implementations.

Tweak Scope class naming and factoring

  1. Rename the class - ResolutionScope?
  2. Remove the Scope class, move Lifetime property to ResolutionScope
  3. Delete the Thread safe scope - why would you be resolving in the same scope in multiple threads?

On second thought, I could see "Use case wide" scopes that might hop threads. But still, shouldn't you have one composition root? Yeah, we can ditch this for now - bring it back if we find an actual use case.

Reorganize codebase

It's really confusing as to what's where, the public stuff isn't consistently in any spot. Clean it up so it's obvious what feature is in what directory.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.