コード例 #1
0
ファイル: Context.cs プロジェクト: DanniSchou/Foxes.Core
        public Context()
        {
            Injector = new Injector();

            Injector.Bind <IInjector>().ToValue(Injector);
            Injector.Bind <IContext>().ToValue(this);

            _configManager = new ConfigManager();
            Injector.Inject(_configManager);
        }
コード例 #2
0
ファイル: CommandGroup.cs プロジェクト: DanniSchou/Foxes.Core
        public void Add <TK>()
        {
            var type = typeof(TK);

            if (!typeof(ICommand <T>).IsAssignableFrom(type))
            {
                throw new ArgumentException($"{type.FullName} is being mapped as a command but does not implement {nameof(ICommand<T>)}");
            }

            _commandTypes.Add(type);

            if (!Injector.IsBound <TK>())
            {
                Injector.Bind <TK>().AsSingle();
            }

            if (_commandTypes.Count == 1)
            {
                EventBus.Subscribe <T>(OnEvent);
            }
        }
コード例 #3
0
 public void Configure()
 {
     Injector.Bind <IEventBus>().ToSingle <EventBus>();
 }
コード例 #4
0
 public void Configure()
 {
     Injector.Bind <ICommandMap>().ToSingle <CommandMap>();
 }