Пример #1
0
        public void LoadFromFile(string fName = "")
        {
            if (fName == "")
            {
                fName = typeof(T).Name + ".xml";
            }

            if (File.Exists(fName))
            {
                DataSaver <T> newInstance = null;
                this.Clear();

                try
                {
                    FileStream             fRead     = new FileStream(fName, FileMode.Open);
                    DataContractSerializer xmlReader = new DataContractSerializer(typeof(DataSaver <T>));
                    newInstance = (DataSaver <T>)xmlReader.ReadObject(fRead);
                    fRead.Close();
                }
                catch
                {
                    newInstance = null;
                }

                if (newInstance != null)
                {
                    this.AddRange(newInstance);
                    newInstance = null;
                }
            }
            else
            {
                this.Clear();
            }
        }
Пример #2
0
 private RelatorioUmidade()
 {
     Dados = new DataSaver <Log>();
     Dados.LoadFromFile("RelatorioUmidade.xml");
 }