Exemplo n.º 1
0
 // may throw
 private static void CheckPropertyBindingCycles(BindingContext newBindingContext, Binding propBinding)
 {
     if (newBindingContext == null || propBinding == null)
     {
         return;
     }
     if (newBindingContext.Contains(propBinding.BindableComponent, ""))
     {
         // this way we do not add a bindingManagerBase to the
         // bindingContext if there isn't one already
         BindingManagerBase bindingManagerBase = newBindingContext.EnsureListManager(propBinding.BindableComponent, "");
         for (int i = 0; i < bindingManagerBase.Bindings.Count; i++)
         {
             Binding binding = bindingManagerBase.Bindings[i];
             if (binding.DataSource == propBinding.BindableComponent)
             {
                 if (propBinding.BindToObject.BindingMemberInfo.BindingMember.Equals(binding.PropertyName))
                 {
                     throw new ArgumentException(string.Format(SR.DataBindingCycle, binding.PropertyName), "propBinding");
                 }
             }
             else if (propBinding.BindToObject.BindingManagerBase is PropertyManager)
             {
                 CheckPropertyBindingCycles(newBindingContext, binding);
             }
         }
     }
 }
Exemplo n.º 2
0
 private static void CheckPropertyBindingCycles(BindingContext newBindingContext, Binding propBinding)
 {
     if (((newBindingContext != null) && (propBinding != null)) && newBindingContext.Contains(propBinding.BindableComponent, ""))
     {
         BindingManagerBase base2 = newBindingContext.EnsureListManager(propBinding.BindableComponent, "");
         for (int i = 0; i < base2.Bindings.Count; i++)
         {
             Binding binding = base2.Bindings[i];
             if (binding.DataSource == propBinding.BindableComponent)
             {
                 if (propBinding.BindToObject.BindingMemberInfo.BindingMember.Equals(binding.PropertyName))
                 {
                     throw new ArgumentException(System.Windows.Forms.SR.GetString("DataBindingCycle", new object[] { binding.PropertyName }), "propBinding");
                 }
             }
             else if (propBinding.BindToObject.BindingManagerBase is PropertyManager)
             {
                 CheckPropertyBindingCycles(newBindingContext, binding);
             }
         }
     }
 }
 private static void CheckPropertyBindingCycles(BindingContext newBindingContext, Binding propBinding)
 {
     if (((newBindingContext != null) && (propBinding != null)) && newBindingContext.Contains(propBinding.BindableComponent, ""))
     {
         BindingManagerBase base2 = newBindingContext.EnsureListManager(propBinding.BindableComponent, "");
         for (int i = 0; i < base2.Bindings.Count; i++)
         {
             Binding binding = base2.Bindings[i];
             if (binding.DataSource == propBinding.BindableComponent)
             {
                 if (propBinding.BindToObject.BindingMemberInfo.BindingMember.Equals(binding.PropertyName))
                 {
                     throw new ArgumentException(System.Windows.Forms.SR.GetString("DataBindingCycle", new object[] { binding.PropertyName }), "propBinding");
                 }
             }
             else if (propBinding.BindToObject.BindingManagerBase is PropertyManager)
             {
                 CheckPropertyBindingCycles(newBindingContext, binding);
             }
         }
     }
 }
 // may throw
 private static void CheckPropertyBindingCycles(BindingContext newBindingContext, Binding propBinding) {
     if (newBindingContext == null || propBinding == null)
         return;
     if (newBindingContext.Contains(propBinding.BindableComponent, "")) {
         // this way we do not add a bindingManagerBase to the
         // bindingContext if there isn't one already
         BindingManagerBase bindingManagerBase = newBindingContext.EnsureListManager(propBinding.BindableComponent, "");
         for (int i = 0; i < bindingManagerBase.Bindings.Count; i++) {
             Binding binding = bindingManagerBase.Bindings[i];
             if (binding.DataSource == propBinding.BindableComponent) {
                 if (propBinding.BindToObject.BindingMemberInfo.BindingMember.Equals(binding.PropertyName))
                     throw new ArgumentException(SR.GetString(SR.DataBindingCycle, binding.PropertyName), "propBinding");
             } else if (propBinding.BindToObject.BindingManagerBase is PropertyManager)
                 CheckPropertyBindingCycles(newBindingContext, binding);
         }
     }
 }
Exemplo n.º 5
0
		public void CtorTest ()
		{
			BindingContext bc = new BindingContext ();

			Assert.IsFalse (bc.IsReadOnly, "CT1");
			Assert.IsFalse (bc.Contains (this), "CT2");
			Assert.IsFalse (bc.Contains (this, String.Empty), "CT3");
			Assert.IsFalse (bc.Contains (this, "Me is String"), "CT4");

			// Test the ICollection interface
			ICollection ic = (ICollection) bc;
			Assert.AreEqual (ic.Count, 0, "CT5");
			Assert.IsFalse (ic.IsSynchronized, "CT6");
			Assert.IsNull (ic.SyncRoot, "CT7");
			object [] arr = new object [] { "A", "B", "C" };
			ic.CopyTo (arr, 0);
			Assert.AreEqual (0, ic.Count, "CT8");
			Assert.IsFalse (ic.GetEnumerator ().MoveNext (), "CT9");
		}
Exemplo n.º 6
0
		public void TestIndexerICurrencyManagerProvider ()
		{
			BindingContext bc = new BindingContext ();
			BindingSource source = new BindingSource ();

			// This way the actual CurrencyManager instance is NOT added to
			// BindingContext
			CurrencyManager cm = (CurrencyManager) bc [source];
			Assert.AreSame (cm, source.CurrencyManager, "A1");
			Assert.AreEqual (false, bc.Contains (source), "A2");
			Assert.AreEqual (0, ((ICollection)bc).Count, "A3");
		}