Ejemplo n.º 1
0
        public static void BindDisposableExecutionOrder(
            this DiContainer container, Type type, int order)
        {
            Assert.That(type.DerivesFrom <IDisposable>(),
                        "Expected type '{0}' to derive from IDisposable", type.Name());

            container.BindInstance(
                ValuePair.New(type, order)).WhenInjectedInto <DisposableManager>();
        }
Ejemplo n.º 2
0
        public static void BindLateTickableExecutionOrder(
            this DiContainer container, Type type, int order)
        {
            Assert.That(type.DerivesFrom <ILateTickable>(),
                        "Expected type '{0}' to derive from ILateTickable", type.Name());

            container.Bind <ValuePair <Type, int> >().WithId("Late")
            .FromInstance(ValuePair.New(type, order)).WhenInjectedInto <TickableManager>();
        }
Ejemplo n.º 3
0
        public static IEnumerable When(Func <bool> cond, IEnumerable whenTrue, IEnumerable whenFalse = null, Func <bool> stopCond = null)
        {
            whenFalse = whenFalse != null ?
                        whenFalse :
                        KeepDoing(Nothing);

            return(SimpleStateMachine(stopCond,
                                      ValuePair.New(cond, whenTrue),
                                      ValuePair.New(Not(cond), whenFalse)
                                      ));
        }
Ejemplo n.º 4
0
 public static IEnumerable <ValuePair <Type, MetadataType> > GetAnnotatedTypes <MetadataType>() where MetadataType : Attribute
 {
     foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
     {
         foreach (var route in type.GetCustomAttributes(true))
         {
             if (route is MetadataType)
             {
                 yield return(ValuePair.New(type, route as MetadataType));
             }
         }
     }
 }
Ejemplo n.º 5
0
        public IApplication RegisterPresenter(IRoute route, Type type, Dictionary <string, ValuePair <IRoute, Type> > dict = null)
        {
            if (!typeof(MonoBehaviour).IsAssignableFrom(type))
            {
                throw new Exception(string.Format("Type '{0}' is not a MonoBehaviour", type));
            }

            container.Bind(type).FromComponentInNewPrefabResource(route.fullPath).AsTransient();
            if (dict != null)
            {
                dict[route.path] = ValuePair.New(route, type);
            }
            return(this);
        }
Ejemplo n.º 6
0
 protected static ConditionCopyNonLazyBinder AddBindingInternal <TDerived>(DiContainer container, TKey key)
     where TDerived : TBase
 {
     return(container.Bind <ValuePair <TKey, Type> >()
            .FromInstance(ValuePair.New(key, typeof(TDerived))));
 }
Ejemplo n.º 7
0
 public void BindTickable <TTickable>(int priority) where TTickable : ITickable
 {
     _container.BindInterfacesAndSelfTo <TTickable>().AsSingle();
     _container.Bind <ValuePair <Type, int> >().FromInstance(ValuePair.New(typeof(TTickable), priority));
 }