private ExceptionManager() { try { OFoodsConfigSection config = AppRuntime.Instance.CurrentApplication.ConfigSource.Config; if (config.Exceptions != null && config.Exceptions.Count > 0) { ExceptionElementCollection exceptionElementCollection = config.Exceptions; foreach (ExceptionElement exceptionElement in exceptionElementCollection) { Type exceptionType = Type.GetType(exceptionElement.Type); if (exceptionType == null) { continue; } if (exceptionType.IsAbstract || !typeof(Exception).IsAssignableFrom(exceptionType)) { continue; } ExceptionHandlingBehavior handlingBehavior = exceptionElement.Behavior; if (exceptionElement.Handlers != null && exceptionElement.Handlers.Count > 0) { foreach (ExceptionHandlerElement exceptionHandlerElement in exceptionElement.Handlers) { Type handlerType = Type.GetType(exceptionHandlerElement.Type); if (handlerType != null) { if (handlerType.IsAbstract || !handlerType.GetInterfaces().Any(p => p.Equals(typeof(IExceptionHandler)))) { continue; } try { IExceptionHandler exceptionHandler = (IExceptionHandler)Activator.CreateInstance(handlerType); this.RegisterHandlerOrig(exceptionType, handlingBehavior, exceptionHandler); } catch { continue; } // try } // if } // foreach - exception handler } else { handlersOrig.Add(exceptionType, new ExceptionConfigItem { Behavior = handlingBehavior, Handlers = new List <IExceptionHandler>() }); } } // foreach - exception BuildResponsibilityChain(); } // if } catch { } }
/// <summary> /// Determines whether the specified element name is excempted from processing. /// </summary> /// <param name="elementName">Name of the element.</param> /// <param name="id">The identifier.</param> /// <param name="exceptions">The exceptions.</param> /// <returns><c>true</c> if the specified element name is excempted from processing; otherwise, <c>false</c>.</returns> public static bool IsExcemptedFromProcessing(string elementName, Guid id, ExceptionElementCollection exceptions) { foreach (ExceptionElement exception in exceptions) { if (!string.IsNullOrEmpty(exception.MetadataId)) { Guid metadataId; Guid.TryParse(exception.MetadataId, out metadataId); if (metadataId.Equals(id)) return true; } if (!string.IsNullOrEmpty(elementName)) { return (string.Compare(elementName, exception.Name, StringComparison.InvariantCultureIgnoreCase) == 0); } } return false; }