Exemplo n.º 1
0
        /// <summary>
        /// Loading xml file
        /// </summary>
        /// <param name="path"></param>
        public override void Load(string path)
        {
            Logger.Log("Language", "Log", "Loading at: " + path);

            if (!File.Exists(path))
            {
                return;
            }
            value = new DatabaseElement <Category>();
            XmlDocument doc = new XmlDocument();

            doc.Load(path);
            XmlNodeList root = doc.ChildNodes.Item(0).ChildNodes;

            foreach (var i in root)
            {
                string   cate = ((XmlNode)i).Name;
                Category c    = new Category();
                c.key    = cate;
                c.labels = new List <Label>();
                value.Elements.Add(c);

                foreach (var j in ((XmlNode)i).ChildNodes)
                {
                    string lab = ((XmlNode)j).Name;
                    Label  l   = new Label();
                    l.key   = lab;
                    l.value = ((XmlNode)j).InnerText;
                    c.labels.Add(l);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loading all player data from folder
        /// </summary>
        /// <param name="path">Directory type</param>
        public override void Load(string path)
        {
            ass = Assembly.GetCallingAssembly();
            LoadPropertiesTypes();
            Logger.Log("Language", "Log", "Loading at: " + path);

            if (!Directory.Exists(path))
            {
                return;
            }
            value = new DatabaseElement <Player>();

            // Get all the file under player folder
            foreach (var i in Directory.GetFiles(path))
            {
                // If it's xml, then it can be read
                if (Path.GetExtension(i) == ".xml")
                {
                    Player playerBuffer = LoadingPlayer(i);
                    if (playerBuffer != null)
                    {
                        value.Elements.Add(playerBuffer);
                    }
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Loading current data from target path <br/>
 /// Use memory stream loading
 /// </summary>
 /// <param name="path">Path</param>
 public virtual void Load(string path)
 {
     byte[] data = File.ReadAllBytes(path);
     using (var ms = new MemoryStream())
     {
         var binform = new BinaryFormatter();
         ms.Write(data, 0, data.Length);
         ms.Seek(0, SeekOrigin.Begin);
         var obj = binform.Deserialize(ms);
         value = (DatabaseElement <T>)obj;
     }
 }