Exemplo n.º 1
0
    void Initialize(
        [Inject] DiContainer diContainer,
        [Inject] DisposableManager dManager,
        [Inject] TickableManager tManager,
        [Inject] IEventsService eventService)
    {
        if (isInitialized)
        {
            return;
        }
        isInitialized = true;


        Container     = diContainer;
        _dManager     = dManager;
        _tManager     = tManager;
        _eventService = eventService;

        //To make IDisposable work, we have to add this instance to the disposable manager
        _dManager.Add(this);

        //Make ITickable and INetworkTickable work
        AddTickable(this);


        //Bind all interfaces for this instance
        Container.Bind <ITickable>().FromInstance(this);
        Container.Bind <IDisposable>().FromInstance(this);
        //Container.BindAllInterfacesFromInstance(this);

        AfterBind();
    }
Exemplo n.º 2
0
    void Initialize(
        [Inject] DiContainer diContainer,
        [Inject] DisposableManager dManager,
        [Inject] TickableManager tManager,
        [Inject] IEventsService eventService)
    {
        if (isInitialized)
        {
            return;
        }
        isInitialized = true;

        PreBind();

        Container     = diContainer;
        _dManager     = dManager;
        _tManager     = tManager;
        _eventService = eventService;

        Profiler.BeginSample("dmanager add");

        //To make IDisposable work, we have to add this instance to the disposable manager
        _dManager.Add(this);
        Profiler.EndSample();

        //Make ITickable work
        Profiler.BeginSample("Add tickable");
        // this takes most of the time
        AddTickable(this);
        Profiler.EndSample();

        //Bind all interfaces for this instance
        Profiler.BeginSample("ITickable fromInstance");
        Container.Bind <ITickable>().FromInstance(this);
        Profiler.EndSample();
        Profiler.BeginSample("IDisposable fromInstance");
        Container.Bind <IDisposable>().FromInstance(this);
        //Container.BindAllInterfacesFromInstance(this);
        Profiler.EndSample();

        Profiler.BeginSample("AfterBind");
        AfterBind();
        Profiler.EndSample();
    }