Bonjour,

Je sérialise en XML un objet comprenant les champs suivants:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
private string m_Directory;
public string Directory
{
	get { return m_Directory;}
	set { m_Directory = value;}
}
 
private string m_Nom;
public string Nom
{
	get { return m_Nom;}
	set { m_Nom = value;}
}
 
public List<string> UsersThatMustReadDSI = new List<string>();
 
public List<Base_Page> Pages = new List<Base_Page>();
Au début de mon application, je souhaite trier mes fichiers XML selon la string Directory, pour celà je lis séquentiellement le fichier... Mais Directory se trouve à la fin, c'est ballot.

Les string "sortent" systématiquement après les List<T>...

J'ai regardé dans les attributs d'XMLSerializer sans trouver mon bonheur.

Donc, ma question, est-il possible de forcer la serialisation à commencer par l'élément voulu ?

Voici le système de sérialisation que j'utilise (je précise que je sais l'utiliser, mais qu'à ce niveau, je ne comprend rien au code) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 
using System;
using System.Xml.Serialization;
using System.IO;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
 
namespace DSI
{
	public class XMLSerialize<T> : MarshalByRefObject where T : new()
	{
		// Le serialiser est statique ainsi il n'est construit qu'une fois par le CLR
		// gain de temps enorme qui evite de faire une reflection à chaque utilisation
 
		static XmlSerializer m_serializer = new XmlSerializer(typeof(T));
		static public T LoadFromFile(string fileName)
		{
			T result;
			try
			{
				using (FileStream input = new FileStream(fileName, FileMode.Open))
				{
					result = (T)m_serializer.Deserialize(input);
				}
			}
			catch
			{
				result = new T();
			}
			return result;
		}
		static public T LoadFromString(string data)
		{
			T result;
 
			try
 
			{
				using (StringReader sr = new StringReader(data))
				{
					result = (T)m_serializer.Deserialize(sr);
				}
			}
			catch
 
			{
				result = new T();
			}
			return result;
		}
		static public T LoadFromStream(Stream stream)
		{
			T result;
 
			try
 
			{
				XmlSerializer read = new XmlSerializer(typeof(T));
				result = (T)m_serializer.Deserialize(stream);
			}
			catch
 
			{
				result = new T();
			}
			return result;
		}
		public void SaveToStream(Stream stream)
		{
			m_serializer.Serialize(stream, this);
		}
		public string SaveToString()
		{
			StringWriter sw = new StringWriter();
			m_serializer.Serialize(sw, this);
			return sw.ToString();
		}
		public void SaveToFile(string fileName)
		{
			using (StreamWriter sm = new StreamWriter(fileName))
			{
				m_serializer.Serialize(sm, this);
			}
		}
	}
 
	//Ma classe de serialisation
	public class XmlDSI : XMLSerialize<XmlDSI>
	{
		public XmlDSI()
		{
 
		}
 
		public XmlDSI(DSI_Patient dsi)
		{
			DSI = dsi;
		}
 
		public DSI_Patient DSI;
	}
 
}
En espérant votre aide, merci ;o)