public BindingCompleteEventArgs(Binding binding, BindingCompleteState state, BindingCompleteContext context, string errorText, Exception exception, bool cancel)
			: base (cancel)
		{
			this.binding = binding;
			this.state = state;
			this.context = context;
			this.error_text = errorText;
			this.exception = exception;
		}
		public void TestBindingCompleteEventArgs ()
		{
			Binding b = new Binding ("TestBind", null, "TestMember");
			BindingCompleteContext c = new BindingCompleteContext ();
			string errorText = "This is an error!";
			Exception ex = new ArgumentNullException ();

			BindingCompleteEventArgs e = new BindingCompleteEventArgs (b, BindingCompleteState.Success, c);

			Assert.AreEqual (b, e.Binding, "A1");
			Assert.AreEqual (BindingCompleteState.Success, e.BindingCompleteState, "A2");
			Assert.AreEqual (c, e.BindingCompleteContext, "A3");
			Assert.AreEqual (false, e.Cancel, "A4");
			Assert.AreEqual (String.Empty, e.ErrorText, "A5");
			Assert.AreEqual (null, e.Exception, "A6");

			BindingCompleteEventArgs e2 = new BindingCompleteEventArgs (b, BindingCompleteState.Success, c, errorText);

			Assert.AreEqual (b, e2.Binding, "B1");
			Assert.AreEqual (BindingCompleteState.Success, e2.BindingCompleteState, "B2");
			Assert.AreEqual (c, e2.BindingCompleteContext, "B3");
			Assert.AreEqual (false, e2.Cancel, "B4");
			Assert.AreEqual (errorText, e2.ErrorText, "B5");
			Assert.AreEqual (null, e2.Exception, "B6");

			BindingCompleteEventArgs e3 = new BindingCompleteEventArgs (b, BindingCompleteState.Success, c, errorText, ex);

			Assert.AreEqual (b, e3.Binding, "C1");
			Assert.AreEqual (BindingCompleteState.Success, e3.BindingCompleteState, "C2");
			Assert.AreEqual (c, e3.BindingCompleteContext, "C3");
			Assert.AreEqual (false, e3.Cancel, "C4");
			Assert.AreEqual (errorText, e3.ErrorText, "C5");
			Assert.AreEqual (ex, e3.Exception, "C6");

			BindingCompleteEventArgs e4 = new BindingCompleteEventArgs (b, BindingCompleteState.Success, c, errorText, ex, true);

			Assert.AreEqual (b, e4.Binding, "D1");
			Assert.AreEqual (BindingCompleteState.Success, e4.BindingCompleteState, "D2");
			Assert.AreEqual (c, e4.BindingCompleteContext, "D3");
			Assert.AreEqual (true, e4.Cancel, "D4");
			Assert.AreEqual (errorText, e4.ErrorText, "D5");
			Assert.AreEqual (ex, e4.Exception, "D6");

		}
Beispiel #3
0
		void FireBindingComplete (BindingCompleteContext context, Exception exc, string error_message)
		{
			BindingCompleteEventArgs args = new BindingCompleteEventArgs (this, 
					exc == null ? BindingCompleteState.Success : BindingCompleteState.Exception,
					context);
			if (exc != null) {
				args.SetException (exc);
				args.SetErrorText (error_message);
			}

			OnBindingComplete (args);
		}
 /// <include file='doc\BindingCompleteEventArgs.uex' path='docs/doc[@for="BindingCompleteEventArgs.BindingCompleteEventArgs3"]/*' />
 /// <devdoc>
 ///    Constructor for BindingCompleteEventArgs.
 /// </devdoc>
 public BindingCompleteEventArgs(Binding binding,
                                 BindingCompleteState state,
                                 BindingCompleteContext context) : this(binding, state, context, string.Empty, null, false) {
 }
 /// <include file='doc\BindingCompleteEventArgs.uex' path='docs/doc[@for="BindingCompleteEventArgs.BindingCompleteEventArgs2"]/*' />
 /// <devdoc>
 ///    Constructor for BindingCompleteEventArgs.
 /// </devdoc>
 public BindingCompleteEventArgs(Binding binding,
                                 BindingCompleteState state,
                                 BindingCompleteContext context,
                                 string errorText) : this(binding, state, context, errorText, null, true) {
 }
 /// <include file='doc\BindingCompleteEventArgs.uex' path='docs/doc[@for="BindingCompleteEventArgs.BindingCompleteEventArgs1"]/*' />
 /// <devdoc>
 ///    Constructor for BindingCompleteEventArgs.
 /// </devdoc>
 public BindingCompleteEventArgs(Binding binding,
                                 BindingCompleteState state,
                                 BindingCompleteContext context,
                                 string errorText,
                                 Exception exception) : this(binding, state, context, errorText, exception, true) {
 }
Beispiel #7
0
        private BindingCompleteEventArgs CreateBindingCompleteEventArgs(BindingCompleteContext context, Exception ex) {
            bool cancel = false;
            string errorText = String.Empty;
            BindingCompleteState state = BindingCompleteState.Success;

            if (ex != null) {
                // If an exception was provided, report that
                errorText = ex.Message;
                state = BindingCompleteState.Exception;
                cancel = true;
            }
            else {
                // If data error info on data source for this binding, report that
                errorText = this.BindToObject.DataErrorText;

                // We should not cancel with an IDataErrorInfo error - we didn't in Everett
                if (!String.IsNullOrEmpty(errorText)) {
                    state = BindingCompleteState.DataError;
                }
            }

            return new BindingCompleteEventArgs(this, state, context, errorText, ex, cancel);
        }
 private BindingCompleteEventArgs CreateBindingCompleteEventArgs(BindingCompleteContext context, Exception ex)
 {
     bool cancel = false;
     string message = string.Empty;
     BindingCompleteState success = BindingCompleteState.Success;
     if (ex != null)
     {
         message = ex.Message;
         success = BindingCompleteState.Exception;
         cancel = true;
     }
     else
     {
         message = this.BindToObject.DataErrorText;
         if (!string.IsNullOrEmpty(message))
         {
             success = BindingCompleteState.DataError;
         }
     }
     return new BindingCompleteEventArgs(this, success, context, message, ex, cancel);
 }
	public BindingCompleteEventArgs(Binding binding, BindingCompleteState state, BindingCompleteContext context, string errorText, System.Exception exception) {}
	public BindingCompleteEventArgs(Binding binding, BindingCompleteState state, BindingCompleteContext context) {}
 /// <summary>
 /// Constructor for BindingCompleteEventArgs.
 /// </summary>
 public BindingCompleteEventArgs(Binding binding,
                                 BindingCompleteState state,
                                 BindingCompleteContext context) : this(binding, state, context, string.Empty, null, false)
 {
 }
 /// <summary>
 /// Constructor for BindingCompleteEventArgs.
 /// </summary>
 public BindingCompleteEventArgs(Binding binding,
                                 BindingCompleteState state,
                                 BindingCompleteContext context,
                                 string errorText) : this(binding, state, context, errorText, null, true)
 {
 }
        public void Ctor_Binding_BindingCompleteState_BindingCompleteContext_String_Exception_Bool(Binding binding, BindingCompleteState state, BindingCompleteContext context, string errorText, Exception exception, bool cancel)
        {
            var e = new BindingCompleteEventArgs(binding, state, context, errorText, exception, cancel);

            Assert.Equal(binding, e.Binding);
            Assert.Equal(state, e.BindingCompleteState);
            Assert.Equal(context, e.BindingCompleteContext);
            Assert.Equal(errorText ?? "", e.ErrorText);
            Assert.Equal(exception, e.Exception);
            Assert.Equal(cancel, e.Cancel);
        }
        public void Ctor_Binding_BindingCompleteState_BindingCompleteContext_String(Binding binding, BindingCompleteState state, BindingCompleteContext context, string errorText)
        {
            var e = new BindingCompleteEventArgs(binding, state, context, errorText);

            Assert.Equal(binding, e.Binding);
            Assert.Equal(state, e.BindingCompleteState);
            Assert.Equal(context, e.BindingCompleteContext);
            Assert.Equal(errorText ?? "", e.ErrorText);
            Assert.Null(e.Exception);
            Assert.True(e.Cancel);
        }
        public void Ctor_Binding_BindingCompleteState_BindingCompleteContext(Binding binding, BindingCompleteState state, BindingCompleteContext context)
        {
            var e = new BindingCompleteEventArgs(binding, state, context);

            Assert.Equal(binding, e.Binding);
            Assert.Equal(state, e.BindingCompleteState);
            Assert.Equal(context, e.BindingCompleteContext);
            Assert.Empty(e.ErrorText);
            Assert.Null(e.Exception);
            Assert.False(e.Cancel);
        }