Example #1
0
        /// <summary>
        /// Loads in defaults from recourses to the dataset upon startup.
        /// </summary>
        public void loadDefaultData()
        {
            traitsDict  = new DataSet1.traitDataTable();
            ancestories = new DataSet1.ancestryDataTable();
            equipment   = new DataSet1.equipmentDataTable();
            experiences = new DataSet1.experienceDataTable();
            types       = new DataSet1.typeDataTable();
            sizes       = new DataSet1.sizeDataTable();

            StringReader stream;

            stream = new StringReader(Properties.Resources.traits_saf);
            traitsDict.ReadXml(stream);

            stream = new StringReader(Properties.Resources.ancestories_saf);
            ancestories.ReadXml(stream);

            stream = new StringReader(Properties.Resources.equipment_saf);
            equipment.ReadXml(stream);

            stream = new StringReader(Properties.Resources.experiences_saf);
            experiences.ReadXml(stream);

            stream = new StringReader(Properties.Resources.types_saf);
            types.ReadXml(stream);

            stream = new StringReader(Properties.Resources.sizes_saf);
            sizes.ReadXml(stream);

            stream.Close();
        }
Example #2
0
        /// <summary>
        /// Loads binary from path, extracts dictionary with xml strings, loads xml strings into fresh databases.
        /// </summary>
        /// <param path="import file location"></param>
        /// TODO:
        /// Find a way to reuse stream here it must be possible
        public void importTables(String path)
        {
            traitsDict  = new DataSet1.traitDataTable();
            ancestories = new DataSet1.ancestryDataTable();
            equipment   = new DataSet1.equipmentDataTable();
            experiences = new DataSet1.experienceDataTable();
            types       = new DataSet1.typeDataTable();
            sizes       = new DataSet1.sizeDataTable();
            units       = new DataSet1.unitDataTable();

            Dictionary <string, string> xmlStringDict;

            FileStream      s = new FileStream(path, FileMode.Open);
            BinaryFormatter b = new BinaryFormatter();

            xmlStringDict = (Dictionary <string, string>)b.Deserialize(s);
            StringReader stream;

            stream = new StringReader(xmlStringDict["ancestories"]);
            ancestories.ReadXml(stream);

            stream = new StringReader(xmlStringDict["traitsDict"]);
            traitsDict.ReadXml(stream);

            stream = new StringReader(xmlStringDict["equipment"]);
            equipment.ReadXml(stream);

            stream = new StringReader(xmlStringDict["experiences"]);
            experiences.ReadXml(stream);

            stream = new StringReader(xmlStringDict["types"]);
            types.ReadXml(stream);

            stream = new StringReader(xmlStringDict["sizes"]);
            sizes.ReadXml(stream);

            stream.Close();
            s.Close();
        }