Xml Serialisierung mit .Net 2 und Generics @Frank



Hallo Frank und auch der Rest der NG,

also jetzt hier meine konkrete Problemstellung zur Xml Serialisierung

Ich habe eine Xml Datei, welche so aussieht (statt werten habe ich hier die
Datentypen angegeben):
<Assignment>
<Control>
<Name>String</Name>
<Type>Integer</Type>
<Filename>String</Filename>
</Control>
<Databases>
<Database>String</Database>
<Database>String</Database>
<Database>String</Database>
</Databases>
<Fields>
<Field>
<GUID>GUID</GUID>
<Cobra>GUID</Cobra>
<David>GUID</David>
</Field>
<Field>
<GUID>GUID</GUID>
<Cobra>GUID</Cobra>
<David>GUID</David>
</Field>
<Field>
<GUID>GUID</GUID>
<Cobra>GUID</Cobra>
<David>GUID</David>
</Field>
<Field>
<GUID>GUID</GUID>
<Cobra>GUID</Cobra>
<David>GUID</David>
</Field>
</Fields>
</Assignment>

und jetzt das wichtigste und wahrscheinlich die Stelle wo mein Fehler liegt
das Objekt:

[XmlRoot(ElementName = "Assignment", IsNullable = false), Serializable]
public sealed class Assignment {
private List<Field> fields;
private List<Database> databases;
private Control control;

[XmlElement(Type = typeof(Control), ElementName = "Control", IsNullable =
false, Form = XmlSchemaForm.Qualified)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public Control Control {
get {
return control;
}

set {
control = value;
}
}


[XmlElement(Type = typeof(Field), ElementName = "Fields", IsNullable
= false, Form = XmlSchemaForm.Qualified)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public List<Field> Fields {
get {
return fields;
}

set {
fields = value;
}
}

[XmlElement(Type = typeof(Database), ElementName = "Databases",
IsNullable = false, Form = XmlSchemaForm.Qualified)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public List<Database> Databases {
get {
return databases;
}

set {
databases = value;
}
}

public Assignment() {
//leere Listen definieren
Fields = new List<Field>();
Databases = new List<Database>();
}

}

an dieser Stelle lasse ich Control weg denn das Funktioniert einwandfrei,
also hier die beiden Item Klassen:
[Serializable]
[DebuggerStepThrough]
[DesignerCategory("Code")]
[XmlType(AnonymousType = true)]
public sealed class Database {
private string name;

[XmlElement(ElementName = "Database", IsNullable = false, Form =
XmlSchemaForm.Qualified, DataType = "string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string Name {
get {
return name;
}

set {
if (value != "") {
name = value;
}
}
}

public Database() {
Name = string.Empty;
}
}

[Serializable]
[DebuggerStepThrough]
[DesignerCategory("Code")]
[XmlType(AnonymousType = true)]
public sealed class Field {

private string guid;

[XmlElement(ElementName = "GUID", IsNullable = false, Form =
XmlSchemaForm.Qualified, DataType = "string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string GUID {
get {
return guid;
}

set {
guid = value;
}
}

private string david;

[XmlElement(ElementName = "David", IsNullable = false, Form =
XmlSchemaForm.Qualified, DataType = "string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string David {
get {
return david;
}

set {
david = value;
}
}

private string cobra;

[XmlElement(ElementName = "Cobra", IsNullable = false, Form =
XmlSchemaForm.Qualified, DataType = "string")]
[EditorBrowsable(EditorBrowsableState.Advanced)]
public string Cobra {
get {
return cobra;
}

set {
cobra = value;
}
}

public Field() {
GUID = string.Empty;
David = string.Empty;
Cobra = string.Empty;
}
}

Jetzt bin ich natürlich für jede Hilfe dankbar.

Grüße
Sascha
.



Relevant Pages

  • RE: Xml Serialisierung mit .Net 2 und Generics @Frank
    ... private Listdatabases; ... private Control control; ... private string name; ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: CreateEventProc error
    ... Private Sub BuildDisplayForm(strPath As String, ... Dim qdf As QueryDef, qdfControls As QueryDef ... Dim ctl As Control, ctlLabel As Control, ctlParent As Control ... Dim strFilter As String, strSuffix As String, strParentName As String, ...
    (microsoft.public.access.forms)
  • Having trouble with multi-select list box in Access
    ... Const mstrcRange_Begin As String ... name of a control that represents the End part of a range ... On Error GoTo ErrHandler ...
    (microsoft.public.access.gettingstarted)
  • Re: All Menu Navigation
    ... i based the implementation on sample code from http://www.asp.net/CSSAdapters/Menu.aspx, which shows how to create decent HTML for a Menu control bound to a SiteMapDataSource. ... public void RenderBeginTag(HtmlTextWriter writer, string cssClass) ... static public void RemoveProblemTypes ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: DataGrid not showing programmatic changes
    ... There's another data grid control that will connect, ... DAO then select the DBGrid32.ocx. ... > Public Property Let Connection(ByVal sConn As String) ...
    (microsoft.public.vb.general.discussion)