XMLSerializer problem
Mit spørgsmål lyder således:jeg vil gerne serialisere følgende output:
<?xml version="1.0"?>
<customStates xmlns="http://schemas.microsoft.com/09/2005/communicator/customStates" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.microsoft.com/09/2005/communicator/customStates/livecommteam/sites/main/ice/Wave%2012%20Docs/CustomActivities.xsd">
<customState ID="1" availability="online">
<activity LCID="1033">Working from Home</activity>
<activity LCID="1036">Equivalent French String for - Working from Home</activity>
<activity LCID="1030">Dansk streng</activity>
</customState>
<customState ID="2" availability="busy">
<activity LCID="1033">In a Live Meeting</activity>
<activity LCID="1036">Equivalent French String for - In a Live Meeting </activity>
<activity LCID="1030">Dansk streng</activity>
</customState>
<customState ID="3" availability="busy">
<activity LCID="1033">Working</activity>
<activity LCID="1030">Working</activity>
<activity LCID="1036">Equivalent French String for - Working</activity>
</customState>
<customState ID="4" availability="do-not-disturb">
<activity LCID="1033">Relaxing with my family</activity>
<activity LCID="1036">Relaxing with my family</activity>
<activity LCID="1030">Relaxing with my family</activity>
</customState>
</customStates>
Jeg har lavet nedstående klasse, men ved ikke hvorledes jeg kan sætte xsi:schemalocation eller hvorledes jeg skal kunne oprette flere "activity" per element i viste xml.
Håber at i kan hjælpe :)
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
namespace UC.DemoSetup
{
/// <summary>
/// Contains information regarding CustomPresence
/// </summary>
[XmlRootAttribute("CustomStates", Namespace = "http://schemas.microsoft.com/09/2005/communicator/customStates", IsNullable = false)]
public class CustomStates
{
private CustomState customState;
public CustomState CustomState
{
get { return this.customState; }
set { this.customState = value; }
}
public CustomStates() { }
public CustomStates(CustomState customState)
{
this.customState = customState;
}
}
public class CustomState
{
private int customStateId;
private string Avalability;
private Activity activity;
[XmlAttribute("ID")]
public int CustomStateID
{
get{return this.customStateId;}
set{this.customStateId = value;}
}
[XmlAttribute("availability")]
public string Availability
{
get{return this.Avalability;}
set{this.Avalability = value;}
}
public Activity Activity
{
get { return this.activity; }
set { this.activity = value; }
}
public CustomState() { }
public CustomState(int customStateId, string availability, Activity activity)
{
this.customStateId = customStateId;
this.Avalability = availability;
this.activity = activity;
}
}
public class Activity
{
private int lcid;
private string presenceName;
[XmlAttribute("LCID")]
public int LCID
{
get { return this.lcid; }
set { this.lcid = value; }
}
[XmlText()]
public string PresenceName
{
get { return this.presenceName; }
set { this.presenceName = value; }
}
public Activity(){}
public Activity(int lcid, string presenceText)
{
this.lcid = lcid;
this.presenceName = presenceText;
}
}
}