Coder Social home page Coder Social logo

sergeysychov / behaviour_inject Goto Github PK

View Code? Open in Web Editor NEW
47.0 47.0 10.0 1.32 MB

Inversion of Control / Dependency Injection tool for Unity3d

License: MIT License

C# 100.00%
c-sharp dependency-injection injection inversion-of-control ioc ioc-container lightweight monobehaviour reflection unity unity3d

behaviour_inject's People

Contributors

mitay-walle avatar sergeysychov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

behaviour_inject's Issues

suspended events

If there are two components, and one of them is registered as dependency, other will not get events

Injection in context initiators

Sometimes there's a need for conditional context configuration, dependent on other contexts.

May be there should be another component ContextCreationInitalizer, that trigger context creation an allow to inject dependencies into context creator

Example scene

Well i was looking up the project, you seem to have all the code, but not created scene, for autocompose and factory example. adding that would complete the tutorial

Multiple dispose

If pre-created dependency is regisetered multiple times as different interfaces, it's Dispose method will be called multiple times accordingly.

A a = Create(); _context = Context.Create(ContextNames.APPLICATION); _context .RegisterDependencyAs<A, B>(a) .RegisterDependencyAs<A, C>(a);

Match unity scenes to contexts

Make it possible to define default context for current scene. This will allow "use hirarchy" option to work even without hierarchy context component and avoid binding prefabs to particular contexts.

Cycled dependencies uncatched.

Using RegisterAsMultiple may cause cycles remain uncatched.
Example stacktrace:

StackOverflowException: The requested operation caused a stack overflow.
System.RuntimeType.GetConstructors_internal (System.Reflection.BindingFlags bindingAttr, System.RuntimeType reflectedType) (at :0)
System.RuntimeType.GetConstructorCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.CallingConventions callConv, System.Type[] types, System.Boolean allowPrefixLookup) (at :0)
System.RuntimeType.GetConstructors (System.Reflection.BindingFlags bindingAttr) (at :0)
System.Type.GetConstructors () (at :0)
BehaviourInject.Context.FindAppropriateConstructor (System.Type resolvingType) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:419)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:391)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:376)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:361)
BehaviourInject.Context.Resolve (System.Type resolvingType) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:347)
BehaviourInject.Internal.AbstractInjecton.GetDependency (System.Type type, BehaviourInject.Context context) (at Assets/BInject/Scripts/BehaviourInject/IMemberInjection.cs:29)
BehaviourInject.Internal.MethodInjection.Inject (System.Object target, BehaviourInject.Context context) (at Assets/BInject/Scripts/BehaviourInject/IMemberInjection.cs:111)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:411)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:376)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:401)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:376)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:361)
BehaviourInject.Context.Resolve (System.Type resolvingType) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:347)
BehaviourInject.Internal.AbstractInjecton.GetDependency (System.Type type, BehaviourInject.Context context) (at Assets/BInject/Scripts/BehaviourInject/IMemberInjection.cs:29)
BehaviourInject.Internal.MethodInjection.Inject (System.Object target, BehaviourInject.Context context) (at Assets/BInject/Scripts/BehaviourInject/IMemberInjection.cs:111)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:411)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:376)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:401)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:376)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:361)
BehaviourInject.Context.Resolve (System.Type resolvingType) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:347)
BehaviourInject.Internal.AbstractInjecton.GetDependency (System.Type type, BehaviourInject.Context context) (at Assets/BInject/Scripts/BehaviourInject/IMemberInjection.cs:29)
BehaviourInject.Internal.MethodInjection.Inject (System.Object target, BehaviourInject.Context context) (at Assets/BInject/Scripts/BehaviourInject/IMemberInjection.cs:111)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:411)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)
BehaviourInject.Context.TryResolve (System.Type resolvingType, System.Object& dependency, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:376)
BehaviourInject.Context.AutocomposeDependency (System.Type resolvingType, System.Int32 hierarchyDepthCount) (at Assets/BInject/Scripts/BehaviourInject/Context.cs:401)
BehaviourInject.Internal.SingleAutocomposeDependency.Resolve (BehaviourInject.Context context, System.Int32 depth) (at Assets/BInject/Scripts/BehaviourInject/IDependency.cs:67)

Consider autocomposing non registered types on demand

lets say Foo is not registered as any dependency
than in following code

class Bar : MonoBehaviour{
   [AutocomposeOnDemand]
//or 
   [Inject(CreateOnDemand = true)]
   private Foo _foo;
}

_foo is filled with Foo instance immidiatly created by Context, without registering it

Optimize ReflectionCache

ReflectionCache.IsInjectible is called too often.
Need to reduce count of this calls and depth of members search

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.