public static CryoContainer RegisterComponent <T>(this CryoContainer container, LifeTime lifeTime)
     where T : Component
 {
     return(container.RegisterProvider <T>(
                new GetComponentProvider <T>(FindComponentHint.ThisGameObject, container.LifeTimeManager, lifeTime),
                null));
 }
 public static CryoContainer RegisterComponent <T>(this CryoContainer container, FindComponentHint hint,
                                                   LifeTime lifeTime = LifeTime.Global)
     where T : Component
 {
     return(container.RegisterProvider <T>(new GetComponentProvider <T>(hint, container.LifeTimeManager, lifeTime),
                                           null));
 }
Beispiel #3
0
 void IInternalContainerBuidler.CreateRootContainer()
 {
     _container = CreateContainer();
     SetupContainer(_container);
     CryoBehaviour.SetRootContainer(_container);
     CryoBuilder.SetRootContainer(_container);
 }
Beispiel #4
0
 public static void SetRootContainer(CryoContainer container)
 {
     if (_rootContainer != null)
     {
         throw new ContainerException("Root container already set");
     }
     _rootContainer = container;
 }
 public static CryoContainer RegisterInstance <TBase, TDerived>(this CryoContainer container, TDerived obj,
                                                                string name = null, LifeTime lifeTime = LifeTime.Global) where TDerived : TBase
 {
     return(container.RegisterProvider <TBase>(
                new InstanceProvider <TDerived>(obj, container.LifeTimeManager, lifeTime), name));
 }
Beispiel #6
0
 /// <summary>
 /// Override this method to customize containers content
 /// </summary>
 protected virtual void SetupContainer(CryoContainer container)
 {
 }
Beispiel #7
0
 public static CryoContainer RegisterSingleton <T>(this CryoContainer container) where T : new()
 {
     return(container.RegisterProvider <T>(new SingletonProvider <T>(LifeTime.Global), null));
 }
Beispiel #8
0
 public static CryoContainer RegisterType <T>(this CryoContainer container) where T : new()
 {
     return(container.RegisterProvider <T>(new FactoryMethodProvider <T>(LifeTime.Global), null));
 }
Beispiel #9
0
 public static CryoContainer RegisterType <T>(this CryoContainer container, Func <T> factoryMethod, string name, LifeTime lifeTime)
 {
     return(container.RegisterProvider <T>(new FactoryMethodProvider <T>(factoryMethod, lifeTime), name));
 }
Beispiel #10
0
 public static CryoContainer RegisterType <T>(this CryoContainer container, string name, LifeTime lifeTime) where T : new()
 {
     return(container.RegisterProvider <T>(new FactoryMethodProvider <T>(lifeTime), name));
 }
Beispiel #11
0
 public static CryoContainer RegisterSceneObject <T>(this CryoContainer container, LifeTime lifeTime) where T : UnityEngine.Object
 {
     return(container.RegisterProvider <T>(new FindObjectProvider <T>(lifeTime), null));
 }
Beispiel #12
0
 public static CryoContainer RegisterType <T>(this CryoContainer container, Func <T> factoryMethod,
                                              LifeTime lifeTime)
 {
     return(container.RegisterProvider <T>(
                new FactoryMethodProvider <T>(factoryMethod, container.LifeTimeManager, lifeTime), null));
 }
Beispiel #13
0
 public static CryoContainer RegisterType <TBase, TDerived>(this CryoContainer container, string name)
     where TDerived : TBase, new()
 {
     return(container.RegisterProvider <TBase>(
                new FactoryMethodProvider <TDerived>(container.LifeTimeManager, LifeTime.Global), name));
 }
Beispiel #14
0
 public static CryoContainer RegisterSceneObject <T>(this CryoContainer container, string path,
                                                     string name = null, LifeTime lifeTime = LifeTime.Global)
 {
     return(container.RegisterProvider <T>(new ScenePathProvider <T>(path, container.LifeTimeManager, lifeTime),
                                           name));
 }
Beispiel #15
0
 /// <summary>
 /// Зарегистрировать синоним
 /// При попытке получить ссылку на тип TBase из контейнера будет извлекаться TDerived
 /// Удобно при использовании с синглтонами, реализующими несколько интерфейсов
 /// </summary>
 public static CryoContainer RegisterAlias <TBase, TDerived>(this CryoContainer container, string name = null,
                                                             string derivedName = null) where TDerived : TBase
 {
     return(container.RegisterProvider <TBase>(new AliasProvider <TDerived>(derivedName), name));
 }
Beispiel #16
0
 public static CryoContainer RegisterInstance <TBase, TDerived>(this CryoContainer container, TDerived obj, LifeTime lifeTime) where TDerived : TBase
 {
     return(container.RegisterProvider <TBase>(new InstanceProvider <TDerived>(obj, lifeTime), null));
 }
Beispiel #17
0
 public static CryoContainer RegisterSceneObject <T>(this CryoContainer container, string path, LifeTime lifeTime)
 {
     return(container.RegisterProvider <T>(new ScenePathProvider <T>(path, lifeTime), null));
 }
Beispiel #18
0
 public static CryoContainer RegisterComponent <T>(this CryoContainer container, string name, LifeTime lifeTime = LifeTime.Global)
     where T : Component
 {
     return(container.RegisterProvider <T>(new GetComponentProvider <T>(FindComponentHint.ThisGameObject, lifeTime), name));
 }
Beispiel #19
0
 public static CryoContainer RegisterSceneObject <TBase, TDerived>(this CryoContainer container, LifeTime lifeTime) where TDerived : UnityEngine.Object, TBase
 {
     return(container.RegisterProvider <TBase>(new FindObjectProvider <TDerived>(lifeTime), null));
 }
Beispiel #20
0
 public static CryoContainer RegisterSingleton <TBase, TDerived>(this CryoContainer container) where TDerived : TBase, new()
 {
     return(container.RegisterProvider <TBase>(new SingletonProvider <TDerived>(LifeTime.Global), null));
 }
Beispiel #21
0
 public static CryoContainer RegisterType <TBase, TDerived>(this CryoContainer container, LifeTime lifeTime) where TDerived : TBase, new()
 {
     return(container.RegisterProvider <TBase>(new FactoryMethodProvider <TDerived>(lifeTime), null));
 }
Beispiel #22
0
 public static CryoContainer RegisterSingleton <TBase, TDerived>(this CryoContainer container, Func <TDerived> factoryMethod, LifeTime lifeTime) where TDerived : TBase
 {
     return(container.RegisterProvider <TBase>(new SingletonProvider <TDerived>(factoryMethod, lifeTime), null));
 }
Beispiel #23
0
 public static CryoContainer RegisterType <TBase, TDerived>(this CryoContainer container, Func <TDerived> factoryMethod) where TDerived : TBase
 {
     return(container.RegisterProvider <TBase>(new FactoryMethodProvider <TDerived>(factoryMethod, LifeTime.Global), null));
 }
Beispiel #24
0
 public static CryoContainer RegisterSingleton <TBase, TDerived>(this CryoContainer container, string name, LifeTime lifeTime) where TDerived : TBase, new()
 {
     return(container.RegisterProvider <TBase>(new SingletonProvider <TDerived>(lifeTime), name));
 }
Beispiel #25
0
 public static CryoContainer RegisterType <TBase, TDerived>(this CryoContainer container, Func <TDerived> factoryMethod, string name, LifeTime lifeTime) where TDerived : TBase, new()
 {
     return(container.RegisterProvider <TBase>(new FactoryMethodProvider <TDerived>(factoryMethod, lifeTime), name));
 }
Beispiel #26
0
 public static CryoContainer RegisterInstance <T>(this CryoContainer container, T obj, string name = null, LifeTime lifeTime = LifeTime.Global)
 {
     return(container.RegisterProvider <T>(new InstanceProvider <T>(obj, lifeTime), name));
 }
Beispiel #27
0
 public static CryoContainer RegisterSingleton <T>(this CryoContainer container, Func <T> factoryMethod)
 {
     return(container.RegisterProvider <T>(new SingletonProvider <T>(factoryMethod, LifeTime.Global), null));
 }
Beispiel #28
0
 public static CryoContainer RegisterType <T>(this CryoContainer container, LifeTime lifeTime) where T : class, new()
 {
     return(container.RegisterProvider <T>(new FactoryMethodProvider <T>(lifeTime), null));
 }
Beispiel #29
0
 public PrefabInstantiator(CryoContainer container)
 {
     _container = container;
 }
Beispiel #30
0
 public static CryoContainer RegisterInstance <T>(this CryoContainer container, T obj, LifeTime lifeTime)
 {
     return(container.RegisterProvider <T>(new InstanceProvider <T>(obj, lifeTime), null));
 }