//*********************************************************************************************************************** //*********************************************************************************************************************** /// <summary> /// Obtiens le marque page. /// </summary> /// <param name="Name">Nom du marque page.</param> /// <returns>Marque page.</returns> //----------------------------------------------------------------------------------------------------------------------- public T Get <T> (string Name) { //------------------------------------------------------------------------------------------------------------------- #region // Implémentation de la Procédure //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- try { //--------------------------------------------------------------------------------------------------------------- if (this.Iso != null) { //----------------------------------------------------------------------------------------------------------- // Le dossier Bookmarks doit exister //----------------------------------------------------------------------------------------------------------- if (Iso.DirectoryExists("Bookmarks")) { //------------------------------------------------------------------------------------------------------- string Pattern = "Bookmarks/{*-" + ToBaseName(Name) + "}"; //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- foreach (string FileID in Iso.GetFileNames(Pattern)) { //--------------------------------------------------------------------------------------------------- if (FileID.Length == 54) { //----------------------------------------------------------------------------------------------- string FileDate = FileID.Substring(1, 15); DateTime Date = DateTime.MinValue; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- if (DateTime.TryParseExact(FileDate, "yyyyMMdd-HHmmss", null, DateTimeStyles.None, out Date)) { //------------------------------------------------------------------------------------------- string FileName = "Bookmarks/" + FileID; using (var File = Iso.OpenFile(FileName, FileMode.Open)) { using (var Sr = new StreamReader(File)) { XmlSerializer Xs = new XmlSerializer(typeof(T)); using (StringReader St = new StringReader(Sr.ReadToEnd())) { XmlReader writer = XmlReader.Create(St); return((T)Xs.Deserialize(writer)); } } } //------------------------------------------------------------------------------------------- } //----------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------- } //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------------------- catch {} //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- return(default(T)); //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- #endregion //------------------------------------------------------------------------------------------------------------------- }
//*********************************************************************************************************************** //----------------------------------------------------------------------------------------------------------------------- #endregion //*********************************************************************************************************************** //*********************************************************************************************************************** /// <summary> /// Obtiens la liste des marques pages. /// </summary> /// <typeparam name="T">Type de l'objet.</typeparam> /// <returns>Tablea contenant les marques pages.</returns> //----------------------------------------------------------------------------------------------------------------------- public IDictionary <T, DateTime> GetEnumerator <T> () { //------------------------------------------------------------------------------------------------------------------- #region // Implémentation de la Procédure //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- var Buffer = new List <KeyValuePair <object, DateTime> > (); //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- try { //--------------------------------------------------------------------------------------------------------------- if (this.Iso != null) { //----------------------------------------------------------------------------------------------------------- // Le dossier Bookmarks doit exister //----------------------------------------------------------------------------------------------------------- if (Iso.DirectoryExists("Bookmarks")) { //------------------------------------------------------------------------------------------------------- string Pattern = "Bookmarks/{*}"; //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- foreach (string FileID in Iso.GetFileNames(Pattern)) { //--------------------------------------------------------------------------------------------------- if (FileID.Length == 54) { //----------------------------------------------------------------------------------------------- string FileDate = FileID.Substring(1, 15); DateTime Date = DateTime.MinValue; //----------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------- if (DateTime.TryParseExact(FileDate, "yyyyMMdd-HHmmss", null, DateTimeStyles.None, out Date)) { //------------------------------------------------------------------------------------------- string FileName = "Bookmarks/" + FileID; using (var File = Iso.OpenFile(FileName, FileMode.Open)) { using (var Sr = new StreamReader(File)) { XmlSerializer Xs = new XmlSerializer(typeof(T)); using (StringReader St = new StringReader(Sr.ReadToEnd())) { XmlReader writer = XmlReader.Create(St); T Object = (T)Xs.Deserialize(writer); Buffer.Add(new KeyValuePair <object, DateTime> (Object, Date)); } } } //------------------------------------------------------------------------------------------- } //----------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------- } //----------------------------------------------------------------------------------------------------------- } //--------------------------------------------------------------------------------------------------------------- } //------------------------------------------------------------------------------------------------------------------- catch {} //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- Dictionary <T, DateTime> Result = new Dictionary <T, DateTime> (); Buffer.Sort(new BookmarksComparer()); foreach (var Item in Buffer) { Result[(T)Item.Key] = Item.Value; } return(Result); //------------------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------------------- #endregion //------------------------------------------------------------------------------------------------------------------- }