コード例 #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
ファイル: BuildUpStack.cs プロジェクト: cococatus/CryoDI
        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);
            }
        }