--- a/client/src/Iri.Modernisation.Data/Models/Loader.cs Tue Jan 19 09:49:26 2010 +0100
+++ b/client/src/Iri.Modernisation.Data/Models/Loader.cs Tue Jan 19 09:49:56 2010 +0100
@@ -20,32 +20,52 @@
/// <typeparam name="ReturnType">Type Désiré</typeparam>
public class Loader<ResultType>
{
+
+ public String Path { get; private set; }
/// <summary>
/// WebClient qui permet de charger le XML distant
/// </summary>
- private WebClient xmlClient = new WebClient();
- private String _path{get;set;}
+ public WebClient xmlClient {get; private set;}
+ /// <summary>
+ /// Fonction permettant de transcrire le document XML en Type désiré
+ /// </summary>
private Func<XDocument, ResultType> ProcessFunction { get; set; }
+ /// <summary>
+ /// Constructeur
+ /// </summary>
+ /// <param name="processFunction">Fonction de transtypage</param>
public Loader(Func<XDocument,ResultType> processFunction)
{
ProcessFunction = processFunction;
-
+ xmlClient = new WebClient();
}
- public void LoadAvailableVideoBooks(String path)
+
+ /// <summary>
+ /// Téléchargement des données
+ /// </summary>
+ /// <param name="path">Chemin du fichier</param>
+ public void Load(String path)
{
- _path = path;
+ Path = path;
xmlClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(xmlClient_DownloadStringCompleted);
xmlClient.DownloadStringAsync(new Uri(path,UriKind.RelativeOrAbsolute));
}
+ /// <summary>
+ /// Une fois le fichier télécharger, on commence le transtypage
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
void xmlClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
+ //On utilise la fonction donnée lors de la construction du Loader pour créer l'objet grâce au fichier XML
ResultType result = ProcessFunction.Invoke(XDocument.Parse(e.Result));
if (LoaderFinished != null)
{
-
+ //Une fois le Transtypage Fini, on lance l'évenement indiquant que le chargement est fini et donnant
+ // en argument l'objet créé.
LoaderFinished(this, new LoaderEventArgs<ResultType>(result));
}
}