void _Initialize( [Inject] DiContainer _container, [Inject] DisposableManager dManager, [Inject] ISerializerService serializerService, [Inject] IEventsService eventService) { if (initialized) { return; } initialized = true; Bind(delayAfterBind); if (bindAllListener != null) { bindAllListener.Dispose(); } bindAllListener = null; Container = _container; _dManager = dManager; _eventService = eventService; _serializerService = serializerService; _dManager.Add(this); OnAfterBind.Execute(); if (!delayAfterBind) { AfterBind(); } else { Observable.NextFrame().Subscribe(e => AfterBind()).AddTo(this); } }
public void Dispose() { if (wasDisposed || Kernel.applicationQuitting || this == null) { return; } wasDisposed = true; Disposables.Dispose(); DisposablesProperty.Dispose(); DisposablesProperty = null; OnDispose(); OnDisposing.Execute(); OnDisposing.Dispose(); OnDisposing = null; OnAfterBind.Dispose(); OnAfterBind = null; //If an error is thrown here, you are trying to dispose a model that was not bound. This should never happen/you should always bind your models and this comment is just here so you know whats wrong :) //_dManager.Remove(this); //If an error is thrown here, you are trying to dispose a model that was not bound. This should never happen/you should always bind your models and this comment is just here so you know whats wrong :) try { _dManager.Remove(this); } catch (Exception e) { if (!skipWarning) // sry, but I have some cases(in my NPC-Nodes) where I have a Model but unbound. I shouldn't have used MVC-Model in the first place.... { UnityEngine.Debug.LogError("Tried to dispose unbound MVC-Model:" + GetType().ToString()); UnityEngine.Debug.LogException(e); } } }
public void Dispose() { if (wasDisposed || Kernel.applicationQuitting || this == null) { return; } wasDisposed = true; Disposables.Dispose(); DisposablesProperty.Dispose(); DisposablesProperty = null; OnDispose(); OnDisposing.Execute(); OnDisposing.Dispose(); OnDisposing = null; OnAfterBind.Dispose(); OnAfterBind = null; _dManager.Remove(this); }