Пример #1
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            lock (this)
            {
                if (!Disposed)
                {
                    Disposed = true;
                    GC.SuppressFinalize(this);

                    _exceptionLogPublisher?.Dispose();
                    _exceptionLogPublisher = null;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionLogPublisher"/> class.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="args">The arguments.</param>
        /// <exception cref="System.ArgumentException">logType</exception>
        /// <exception cref="TypeAccessException"></exception>
        public ExceptionLogPublisher(NameValueCollection parameters, params object[] args)
        {
            Disposed = false;
            _exceptionLogPublisher = null;

            var type = parameters["logType"];

            if (string.IsNullOrWhiteSpace(type))
            {
                throw new ArgumentException(string.Format("ExceptionLogPublisher: cannot find logType attribute for the following named instance: '{0}'", parameters["name"]), "logType");
            }

            var objectType = Type.GetType(type);

            if (objectType == null)
            {
                throw new TypeAccessException(string.Format("Unable to locate class type '{0}' for the following named instance: '{1}'", type, parameters["name"]));
            }

            _exceptionLogPublisher = ClassFactoryActivator.CreateInstance <IExceptionLogPublisher>(objectType, parameters);
        }