コード例 #1
0
        /// <summary>
        /// Creates a bulb item for each exception to catch.
        /// </summary>
        public IEnumerable<IntentionAction> CreateBulbItems()
        {
            if (null == _cachedElement)
                return Enumerable.Empty<IntentionAction>();

            _generator = new TryCatchBlockGenerator(_provider);

            IEnumerable<string> unhandledExceptions = GetUnhandledExceptions(_cachedElement);
            List<IBulbAction> actions = new List<IBulbAction>();
            foreach (string documentedExceptionType in unhandledExceptions)
                actions.Add(new CatchExceptionBulbItem(documentedExceptionType, _generator));

            // Add "catch all" item if there are several exceptions available
            if (actions.Count > 1)
                actions.Add(this);

            return actions.ToContextAction();
        }
コード例 #2
0
 internal CatchExceptionBulbItem(string exceptionTypeName, TryCatchBlockGenerator generator)
 {
     _exceptionTypeName = exceptionTypeName;
     _generator = generator;
 }