У меня есть несколько производных классов для сериализации в XML: [code] public void Main() { LevelCollection collection = new LevelCollection(); collection.Add(new SubLevel1("aaa")); collection.Add(new SubLevel2("bbb"));
XmlSerializer serializer = new XmlSerializer(typeof(LevelCollection));
StringWriter sw = new StringWriter(); XmlWriter writer = XmlWriter.Create(sw); serializer.Serialize(writer, collection); string xml = sw.ToString(); TestContext.WriteLine(xml); }
[XmlInclude(typeof(SubLevel1))] [XmlInclude(typeof(SubLevel2))] [XmlRoot("LevelCollection")] public class LevelCollection : ICollection { protected List m_Levels;
public List Levels { get { return m_Levels; } set { m_Levels = value; } }
public LevelCollection() { m_Levels = new List(); }
[XmlIgnore] public int Count { get { return m_Levels.Count; } }
public bool IsReadOnly { get; set; }
public void Add(Level level) { m_Levels.Add(level); }
public void Clear() { m_Levels.Clear(); }
public bool Contains(Level item) { return m_Levels.Contains(item); }
public void CopyTo(Level[] array, int arrayIndex) { m_Levels.CopyTo(array, arrayIndex); }
public IEnumerator GetEnumerator() { return m_Levels.GetEnumerator(); }
public bool Remove(Level item) { return m_Levels.Remove(item); }
У меня есть несколько производных классов для сериализации в XML:
public void Main()
{
LevelCollection collection = new LevelCollection();
collection.Add(new SubLevel1( aaa ));
collection.Add(new SubLevel2( bbb ));
У меня есть ответ на запрос от SalesForce, и я пытаюсь десериализовать его в свою модель. Проблема в том, что результат имеет xsi:type= QueryResult , но также и LP_QuoteInformation имеет xsi:type= QueryResult .
У меня есть ответ на запрос от SalesForce, и я пытаюсь десериализовать его в свою модель.
Проблема в том, что результат содержит xsi:type= QueryResult , но также LP_QuoteInformation имеет xsi:type= QueryResult .
Поэтому при десериализации моей...