1

Closed

XMLDigester SetPropertyRule OnBegin bug

description

This seems to correct the null problem because actualName and actualValue revert to null once out of the scope :
 
 
    /// <summary>
    /// Process the start of this element.
    /// </summary>
    public override void OnBegin()
    {
        // determine actual 'name' and 'value'
        string actualName = null;
        string actualValue = null;
 
        for(int i=0; i<this.Digester.Attributes.Count; i++)
        {
            string name = this.Digester.Attributes.GetKey(i);
            string value = this.Digester.Attributes[i];
            if(name == this.name)
            {
                actualName = name;
                actualValue = value;
                // populate object's property
                object top = this.Digester.Peek();
                PropertyInfo prop = top.GetType().GetProperty(actualName, BindingFlags.Public | BindingFlags.Instance);
                prop.SetValue(top, Convert.ChangeType(actualValue, prop.PropertyType), null);
                break;
            }
            else if(name == this.value)
            {
                actualName = value;
                actualValue = name;
                // populate object's property
                object top = this.Digester.Peek();
                PropertyInfo prop = top.GetType().GetProperty(actualName, BindingFlags.Public | BindingFlags.Instance);
                prop.SetValue(top, Convert.ChangeType(actualValue, prop.PropertyType), null);
                break;
            }
        }
 
    }
Closed May 10, 2007 at 3:26 PM by JoeBlack

comments