using System; using System.Xml; using System.Collections; using System.Collections.Generic; using System.Linq; namespace ParamLang { #region Définition des constantes et variables globales // Class de déclaration des variables globales d'application public sealed class GlobalLang { #region Définition des constantes globales // public const string Ver = ""; // public const string Name = ""; // public const string Desc = ""; // public const string Lang = ""; #endregion #region Définition des variable statique booleen // public static bool GlobalParamApp; #endregion #region Routines d'accées aux variables globales static string _Ver; public static string Ver { get { return _Ver; } set { _Ver = value; } } static string _Desc; public static string Desc { get { return _Desc; } set { _Desc = value; } } #endregion #region Routines d'accées aux listes de variables globales public static class Lang { static List _Lang; // Static List instance static Lang() // Allocate the list. { _Lang = new List(); } public static void LangRec(string value) // Record this value in the list. { _Lang.Add(value); } public static string LangLoad(int i) // Write out the results. { string value = _Lang[i]; return (value); } } public static class Frm { static List _Frm; // Static List instance static Frm() // Allocate the list. { _Frm = new List(); } public static void FrmRec(string value) // Record this value in the list. { _Frm.Add(value); } public static string FrmLoad(int i) // Write out the results. { string value = _Frm[i]; return (value); } } public static class Name { static List _Name; // Static List instance static Name() // Allocate the list. { _Name = new List(); } public static void NameRec(string value) // Record this value in the list. { _Name.Add(value); } public static string NameLoad(int i) // Write out the results. { string value = _Name[i]; return (value); } } public static class Text { static List _Text; // Static List instance static Text() // Allocate the list. { _Text = new List(); } public static void TextRec(string value) // Record this value in the list. { _Text.Add(value); } public static string TextLoad(int i) // Write out the results. { string value = _Text[i]; return (value); } } public static class Help { static List _Help; // Static List instance static Help() // Allocate the list. { _Help = new List(); } public static void HelpRec(string value) // Record this value in the list. { _Help.Add(value); } public static string HelpLoad(int i) // Write out the results. { string value = _Help[i]; return (value); } } #endregion } #endregion #region Lecture/Ecriture du fichiers Xml public class Lang { #region Lecture du fichiers Xml et passage en variables globales public static void LoadLang() { // Create an isntance of XmlTextReader and call Read method to read the file XmlTextReader TextReader = new XmlTextReader("ParamLang.xml"); TextReader.Read(); XmlDocument XlmReader = new XmlDocument(); XlmReader.Load("ParamLang.xml"); while (TextReader.Read()) { switch (TextReader.NodeType) { case System.Xml.XmlNodeType.Element: { if (TextReader.Name.Equals("Ver")) { GlobalLang.Ver = TextReader.ReadString(); } if (TextReader.Name.Equals("Description")) { GlobalLang.Desc = TextReader.ReadString(); } if (TextReader.Name.Equals("Language")) { XmlNode objNode; XmlNode root = XlmReader.DocumentElement; objNode = root.SelectSingleNode("//frm[@id='01']"); GlobalLang.Name.NameRec((string)objNode.Attributes[0].InnerText.ToString()); GlobalLang.Text.TextRec((string)objNode.Attributes[1].InnerText.ToString()); GlobalLang.Help.HelpRec((string)objNode.Attributes[2].InnerText.ToString()); //objNode = root.SelectSingleNode("//add[@name='CharDB']"); //GlobalDb.ConnName.ConnNameRec((string)objNode.Attributes[0].InnerText.ToString()); //GlobalDb.ConnChain.ConnChainRec((string)objNode.Attributes[1].InnerText.ToString()); //GlobalDb.ConnProv.ConnProvRec((string)objNode.Attributes[2].InnerText.ToString()); break; } break; } } } TextReader.Close(); } #endregion } #endregion }