tags:

views:

13

answers:

0

When object with dictionary serialized into xml file, the dictionary items tags get strange prefix.

[DataContractAttribute()]
    public class TestClass
    {        
        private Dictionary<string, SomeThing> _attributes = new Dictionary<string, SomeThing>();

        [DataMember()]
        public Dictionary<string, SomeThing> Attributes
        {
            get { return _attributes; }
            set { _attributes  = value; }
        }
    }

[DataContractAttribute()]
public class SomeThing
{
    [DataMember()]
    public string Value1
    {
        get { return _value1; }
        set { _value1 = value; }
    }                
    private string _value1;

    [DataMember()]
    public string Value2
    {
        get { return _value2; }
        set { _value2 = value; }
    }
    private string _value2;

}

The generated xml contains this:

<d2p1:KeyValueOfstringSomeThinghZuf0B2W>
      <d2p1:Key>Attribute1</d2p1:Key>
      <d2p1:Value>
        <Value1>123</Value1>
        <Value2>453</Value2>
      </d2p1:Value>
</d2p1:KeyValueOfstringSomeThinghZuf0B2W>

is it possible to remove 'd2p1' and rename 'KeyValueOfstringSomeThinghZuf0B2W'?