예제 #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>();
        }
예제 #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>();
        }
예제 #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)
                                      ));
        }
예제 #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));
             }
         }
     }
 }
예제 #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);
        }
예제 #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))));
 }
 public void BindTickable <TTickable>(int priority) where TTickable : ITickable
 {
     _container.BindInterfacesAndSelfTo <TTickable>().AsSingle();
     _container.Bind <ValuePair <Type, int> >().FromInstance(ValuePair.New(typeof(TTickable), priority));
 }