protected void SetEventLogging(bool newState, bool showProblems)
        {
            StringBuilder problems = new StringBuilder();

            // Do for all events regardless of what's displayed in the
            // tree
            foreach (EventInfo ei in ObjType.GetEvents(ReflectionHelper.ALL_BINDINGS))
            {
                try {
                    EventLogList.ObjectEvent oe = new EventLogList.ObjectEvent(Obj, ei);
                    ObjectBrowser.EventLog.ToggleLogging(oe, _objInfo.GetName(), newState);
                } catch (Exception ex) {
                    // The outer exception may be a wrapper
                    Exception showException = ex.InnerException;
                    if (showException == null)
                    {
                        showException = ex;
                    }
                    problems.Append("\n\n" + ei.Name + " - ");
                    problems.Append(showException.Message);
                    problems.Append(" (");
                    problems.Append(showException.GetType().FullName);
                    problems.Append(")");
                }
            }
            if (showProblems && problems.Length != 0)
            {
                ErrorDialog.Show
                    ("The following events were not enabled for "
                    + "logging due to errors:"
                    + problems.ToString(),
                    "Some Events Were not Enabled",
                    MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
		protected void SetEventLogging(bool newState, bool showProblems)
		{
			StringBuilder problems = new StringBuilder();
			// Do for all events regardless of what's displayed in the
			// tree
			foreach (EventInfo ei in ObjType.GetEvents(ReflectionHelper.ALL_BINDINGS)) {
				try {
					EventLogList.ObjectEvent oe = new EventLogList.ObjectEvent(Obj, ei);
					ObjectBrowser.EventLog.ToggleLogging(oe, _objInfo.GetName(), newState);
				} catch (Exception ex) {
					// The outer exception may be a wrapper
					Exception showException = ex.InnerException;
					if (showException == null)
						showException = ex;
					problems.Append("\n\n" + ei.Name + " - ");
					problems.Append(showException.Message);
					problems.Append(" (");
					problems.Append(showException.GetType().FullName);
					problems.Append(")");
				}
			}
			if (showProblems && problems.Length != 0) {
				ErrorDialog.Show
					("The following events were not enabled for "
					+ "logging due to errors:"
					+ problems.ToString(),
					"Some Events Were not Enabled",
					MessageBoxIcon.Error);
			}
		}