예제 #1
0
        private void HandleCircularDependency(int from)
        {
            if (OnCircularDependency == Reaction.Ignore)
            {
                return;
            }

            var builder = new StringBuilder();

            builder.Append("Type: " + _stack[from].Object.GetType() + ". Property: " + _stack[from].PropertyName);
            for (int i = from + 1; i < _stack.Count; ++i)
            {
                builder.AppendLine(" -> ");
                builder.Append("Type: " + _stack[i].Object.GetType() + ". Property: " + _stack[i].PropertyName);
            }

            switch (OnCircularDependency)
            {
            case Reaction.LogWarning:
                DILog.LogWarning("Circular dependency found: " + builder.ToString());
                break;

            case Reaction.LogError:
                DILog.LogError("Circular dependency found: " + builder.ToString());
                break;

            case Reaction.ThrowException:
                throw new CircularDependencyException(builder.ToString());
            }
        }
예제 #2
0
        private void CallInitialize()
        {
            var initializables = _initializables;

            _initializables = new List <IInitializable>();
            foreach (var initializable in initializables)
            {
                try
                {
                    initializable.Initialize();
                }
                catch (Exception ex)
                {
                    DILog.LogError("Exception in Initialize: " + ex);
                }
            }

            var lateInitializables = _lateInitializables;

            _lateInitializables = new List <ILateInitializable>();
            foreach (var lateInitializable in lateInitializables)
            {
                try
                {
                    lateInitializable.LateInitialize();
                }
                catch (Exception ex)
                {
                    DILog.LogError("Exception in LateInitialize: " + ex);
                }
            }
        }
예제 #3
0
 private void OnSceneUnloaded(Scene scene)
 {
     DILog.Log($"[LifetimeManager] Scene unloaded: {scene.name} ({scene.handle})");
     if (_entries.TryGetValue(scene.handle, out var entry))
     {
         entry.Dispose();
         _entries.Remove(scene.handle);
     }
 }
예제 #4
0
        private void HandleLifetimeError(string message)
        {
            switch (OnLifetimeError)
            {
            case Reaction.LogWarning:
                DILog.LogWarning(message);
                break;

            case Reaction.LogError:
                DILog.LogError(message);
                break;

            case Reaction.ThrowException:
                throw new WrongLifetimeException(message);
            }
        }