Estimate a code snippet

  • Thread starter Thread starter Vladimir Nesterovsky
  • Start date Start date
V

Vladimir Nesterovsky

I've found this curious code in the System.Windows.Forms.dll:

Class: System.Windows.Forms.BindToObject

internal void CheckBinding()
{
if (((this.owner == null) ||
(this.owner.BindableComponent == null)) ||
!this.owner.ControlAtDesignTime())
{
if (((this.owner.BindingManagerBase != null) &&
(this.fieldInfo != null)) &&
(this.owner.BindingManagerBase.IsBinding &&
!(this.owner.BindingManagerBase is CurrencyManager)))
{
this.fieldInfo.RemoveValueChanged(
this.owner.BindingManagerBase.Current,
new EventHandler(this.PropValueChanged));
}
if ((((this.owner != null) &&
(this.owner.BindingManagerBase != null)) &&
((this.owner.BindableComponent != null) &&
this.owner.ComponentCreated)) &&
this.IsDataSourceInitialized)
{
string text1 = this.dataMember.BindingField;
this.fieldInfo =
this.owner.BindingManagerBase.GetItemProperties().Find(text1, true);
if (((this.owner.BindingManagerBase.DataSource != null) &&
(this.fieldInfo == null)) && (text1.Length > 0))
{
object[] objArray1 = new object[] { text1 } ;
throw new ArgumentException(
SR.GetString("ListBindingBindField", objArray1),
"dataMember");
}
if (((this.fieldInfo != null) &&
this.owner.BindingManagerBase.IsBinding) &&
!(this.owner.BindingManagerBase is CurrencyManager))
{
this.fieldInfo.AddValueChanged(
this.owner.BindingManagerBase.Current,
new EventHandler(this.PropValueChanged));
}
}
else
{
this.fieldInfo = null;
}
}
}

Estimate it. Cheer!

P.S. decompiled with .NET Reflector.
 
I've found this curious code in the System.Windows.Forms.dll:
Class: System.Windows.Forms.BindToObject

internal void CheckBinding()
{
if ((this.owner == null) || ...)
{
if ((this.owner.BindingManagerBase != null) && ...

In spite of silence I want to believe someone from MS will fix this buggy
code.
When (this.owner == null) you are asking for NullReferenceException.
 
Back
Top