public IInjectionBinding BindSignalCrossContext <S>() { IInjectionBinding binding = injectionBinder.GetBinding <S>() ?? injectionBinder.Bind <S>(); binding.CrossContext(); object instance = injectionBinder.GetInstance <S>(); binding.ToValue(instance); return(binding); }
protected override void instantiateCoreComponents() { base.instantiateCoreComponents(); IEventDispatcher dispatcher = injectionBinder.GetInstance <IEventDispatcher>(ContextKeys.CONTEXT_DISPATCHER) as IEventDispatcher; if (dispatcher != null) { crossContextDispatcher = injectionBinder.GetInstance <IEventDispatcher>(ContextKeys.CROSS_CONTEXT_DISPATCHER) as IEventDispatcher; (crossContextDispatcher as ITriggerProvider).AddTriggerable(dispatcher as ITriggerable); } }
public override void MapBindings(ICommandBinder commandBinder, ICrossContextInjectionBinder injectionBinder, IMediationBinder mediationBinder) { var _logger = injectionBinder.GetInstance <LogSignal>(); var _serverSettings = injectionBinder.GetInstance <ServerSettingsData>(); _networkService = new UnityNetworkingService(Settings, _serverSettings, _logger); _networkEvents = new UnityNetworkingEvents(); //Bind Settings Object injectionBinder.Bind <UnityNetworkingData>().ToValue(Settings).ToSingleton().CrossContext(); injectionBinder.Bind <UnityNetworkingService>().ToValue(_networkService).ToSingleton().CrossContext(); injectionBinder.Bind <UnityNetworkingEvents>().ToValue(_networkEvents).ToSingleton().CrossContext(); //Bind Mediators to Views mediationBinder.Bind <UnityNetworkManagerView>().To <UnityNetworkManagerMediator>(); }
public static void DoSomething() { var stringBuilder = new StringBuilder(); for (var y = _injectionBinder.GetInstance <IDataService>().GridHeight - 1; y >= 0; y--) { stringBuilder.Append("["); for (var x = 0; x < _injectionBinder.GetInstance <IDataService>().GridWidth; x++) { var isTransform = _injectionBinder.GetInstance <IGridModel>().Grid[x, y] == null ? "0" : "3"; stringBuilder.Append($"{isTransform}"); } stringBuilder.Append("]\n"); } UnityEngine.Debug.Log(stringBuilder.ToString()); }
public static TAbstract BindCrossContextSingletonSafely <TAbstract, TConcrete>(this ICrossContextInjectionBinder injectionBinder) { IInjectionBinding binding = injectionBinder.GetBinding <TAbstract>(); if (binding == null) { injectionBinder.Bind <TAbstract>().To <TConcrete>().ToSingleton().CrossContext(); } TAbstract instance = injectionBinder.GetInstance <TAbstract>(); return(instance); }
public static TDirect BindCrossContextSingletonSafely <TDirect>(this ICrossContextInjectionBinder injectionBinder, object toObject) { IInjectionBinding binding = injectionBinder.GetBinding <TDirect>(); if (binding == null) { injectionBinder.Bind <TDirect>().To(toObject).ToSingleton().CrossContext(); } TDirect instance = injectionBinder.GetInstance <TDirect>(); return(instance); }
public override void MapBindings(ICommandBinder commandBinder, ICrossContextInjectionBinder injectionBinder, IMediationBinder mediationBinder) { commandBinder.Bind <LogSignal>().To <LogSignalCommand>(); var _logger = injectionBinder.GetInstance <LogSignal>(); injectionBinder.Bind <ServerSettingsData>().ToValue(Settings).ToSingleton().CrossContext(); _events = new PlayFabServerEvents(); injectionBinder.Bind <PlayFabServerEvents>().ToValue(_events).ToSingleton().CrossContext(); _service = new PlayFabServerService(_logger, _events, Settings); injectionBinder.Bind <PlayFabServerService>().ToValue(_service).ToSingleton().CrossContext(); }
public static T StrangeNew <T>() where T : class { return(binder.GetInstance <T>()); }