当前位置: 首页>>代码示例>>C#>>正文


C# ExceptionHandler类代码示例

本文整理汇总了C#中ExceptionHandler的典型用法代码示例。如果您正苦于以下问题:C# ExceptionHandler类的具体用法?C# ExceptionHandler怎么用?C# ExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ExceptionHandler类属于命名空间,在下文中一共展示了ExceptionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DelHandler

 /// <summary>
 /// 移除处理类
 /// </summary>
 /// <param name="handler"></param>
 private static void DelHandler(ExceptionHandler handler)
 {
     if (handlers.ContainsKey(handler.ToString()))
     {
         handlers.Remove(handler.ToString());
     }
 }
开发者ID:rbmyself,项目名称:ipmsnew,代码行数:11,代码来源:ExceptionHandlerFactory.cs

示例2: TryParse

		private static ValueOrError<CrontabSchedule> TryParse(string expression, ExceptionHandler onError)
		{
			if (expression == null)
				throw new ArgumentNullException("expression");

			var tokens = expression.Split(_separators, StringSplitOptions.RemoveEmptyEntries);

			if (tokens.Length != 5)
			{
				return ErrorHandling.OnError(() => new CrontabException(string.Format(
						   "'{0}' is not a valid crontab expression. It must contain at least 5 components of a schedule "
						   + "(in the sequence of minutes, hours, days, months, days of week).",
						   expression)), onError);
			}

			var fields = new CrontabField[5];

			for (var i = 0; i < fields.Length; i++)
			{
				var field = CrontabField.TryParse((CrontabFieldKind)i, tokens[i], onError);
				if (field.IsError)
					return field.ErrorProvider;

				fields[i] = field.Value;
			}

			return new CrontabSchedule(fields[0], fields[1], fields[2], fields[3], fields[4]);
		}
开发者ID:ASK-sa,项目名称:ASK.ServEasy,代码行数:28,代码来源:CrontabSchedule.cs

示例3: AddHandler

 /// <summary>
 /// 添加处理类
 /// </summary>
 /// <param name="handler"></param>
 private static void AddHandler(ExceptionHandler handler)
 {
     if (!handlers.ContainsKey(handler.ToString()))
     {
         handlers.Add(handler.ToString(), handler);
     }
 }
开发者ID:rbmyself,项目名称:ipmsnew,代码行数:11,代码来源:ExceptionHandlerFactory.cs

示例4: ExceptionHandlerTreeNode

 public ExceptionHandlerTreeNode( ExceptionHandler handler ) :
     base( TreeViewImage.Method, handler )
 {
     this.handler = handler;
     this.Text = handler.Options.ToString();
     this.EnableLatePopulate();
 }
开发者ID:jogibear9988,项目名称:ormbattle,代码行数:7,代码来源:ExceptionHandlerTreeNode.cs

示例5: Main

 static void Main()
 {
     ExceptionHandler EH = new ExceptionHandler();
         AppDomain.CurrentDomain.UnhandledException += EH.ThreadExceptionHandle;
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         _LoginForm = new LoginForm();
         Application.Run(_LoginForm); // spawn
 }
开发者ID:justinwillcott,项目名称:huggle,代码行数:9,代码来源:Program.cs

示例6: OnError

		internal static ExceptionProvider OnError(ExceptionProvider provider, ExceptionHandler handler)
		{
			Debug.Assert(provider != null);

			if (handler != null)
				handler(provider());

			return provider;
		}
开发者ID:ASK-sa,项目名称:ASK.ServEasy,代码行数:9,代码来源:ErrorHandling.cs

示例7: When_rethrows_if_no_handler

        public void When_rethrows_if_no_handler()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            int invoke = 0;
            Action action = () => invoke++;

            Assert.Throws<NotImplementedException>(() => exception.On<AbandonedMutexException>(action).When(() => { throw new NotImplementedException(); }));
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:9,代码来源:OnSpec.cs

示例8: Main

 static void Main()
 {
     ExceptionHandler EH = new ExceptionHandler();
     AppDomain.CurrentDomain.UnhandledException += EH.ThreadExceptionHandle;
     Application.Init ();
     LoginForm = new Forms.LoginForm();
     LoginForm.Show ();
     Application.Run ();
 }
开发者ID:se4598,项目名称:huggle,代码行数:9,代码来源:Program.cs

示例9: Handle_ExceptionWhichNoSpecificHandlerCanHandle_RepositoryViolationExceptionThrown

        public void Handle_ExceptionWhichNoSpecificHandlerCanHandle_RepositoryViolationExceptionThrown()
        {
            ExceptionHandler handler = new ExceptionHandler();
            Exception e = new Exception();

            Action act = () => handler.Handle(e);

            act.ShouldThrow<RepositoryViolationException>(actual => ReferenceEquals(actual.InnerException, e));
        }
开发者ID:popcatalin81,项目名称:DataAccess,代码行数:9,代码来源:ExceptionHandlerTests.cs

示例10: When_invokes_target

        public void When_invokes_target()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            int invoke = 0;
            Action action = () => Console.WriteLine("caught");

            exception.On<Exception>(action).When(() => invoke++);
            invoke.ShouldBe(1);
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:10,代码来源:OnSpec.cs

示例11: InstallExceptionHandler

		public static void InstallExceptionHandler(this Application application, ExceptionHandler exceptionHandler)
		{
			const string WarningFormat =
				"If the TaskScheduler used does not implements the {0} interface," +
				" it could not intercept exceptions thrown in secondary threads.";

			Debug.WriteLine(string.Format(WarningFormat, typeof(ILoggerTaskScheduler).Name));

			singletonExceptionHandler.Set(exceptionHandler);
			exceptionHandler.Install();
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:11,代码来源:ApplicationExtensions.cs

示例12: When_invokes_exception_handler_on_exception

        public void When_invokes_exception_handler_on_exception()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            int invoke = 0;
            Action action = () => invoke++;

            exception.On<NotImplementedException>(action).When(() => { throw new NotImplementedException(); });

            invoke.ShouldBe(1);
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:11,代码来源:OnSpec.cs

示例13: Throw

 private bool Throw(ExceptionHandler handler)
 {
     try
     {
         throw new Exception("ExceptionHandlerTests");
     }
     catch (Exception e)
     {
         return handler.HandleException(e);
     }
 }
开发者ID:tarik-s,项目名称:Meticulous,代码行数:11,代码来源:ExceptionHandlerTests.cs

示例14: On_Exception_adds_exception_and_target_invocation

        public void On_Exception_adds_exception_and_target_invocation()
        {
            var exceptions = new Dictionary<Type, Action>();
            var exception = new ExceptionHandler(exceptions);
            Action action = () => Console.WriteLine("caught");

            exception.On<Exception>(action);

            exceptions.ContainsKey(typeof(Exception));
            exceptions.ContainsValue(action);
            exceptions.Count.ShouldBe(1);
        }
开发者ID:garfieldmoore,项目名称:Exceptions,代码行数:12,代码来源:OnSpec.cs

示例15: handleException

        static void handleException(Exception e)
        {
            var handler = new ExceptionHandler
            {
                Exception = e,
                LoggedOnUser = GlobalProperties.loggedOnUser,
                Mode = Mode.Online
            };

            handler.handleException();
            MessageBox.Show("An error was detected. An email has been sent to Development. LAD will now close.", "Error");
            Application.Exit();
        }
开发者ID:robertfall,项目名称:LAD,代码行数:13,代码来源:Program.cs


注:本文中的ExceptionHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。