Exemplo n.º 1
0
        /// <summary>
        /// Retrieves the saved object in the file
        /// </summary>
        /// <returns>Saved information</returns>
        public StorageDetails Retrieve()
        {
            StorageDetails storageDetails = null;
            FileStream     input          = null;

            try
            {
                input          = new FileStream(FILE_NAME, FileMode.Open, FileAccess.Read);
                storageDetails = (StorageDetails)formatter.Deserialize(input);
            }
            catch (IOException)
            {
                //do nothing
            }
            catch (SerializationException)
            {
                //do nothing
            }
            finally
            {
                if (input != null)
                {
                    input.Close();
                }
                else
                {
                    string defaultFolderPath = @"C:\seeSharpSE\";
                    storageDetails = new StorageDetails(defaultFolderPath);
                }
            }
            return(storageDetails);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves the repository details  saved to a file if available
        /// </summary>
        public static void initializeSavedInfo()
        {
            bool status;

            if (Directory.Exists(defaultFolderPath))
            {
                string serializeFileName = "seeSharpDB";
                if (File.Exists(serializeFileName))
                {
                    StorageDetailsSR storageDetailsSR = new StorageDetailsSR();
                    storageDetails = storageDetailsSR.Retrieve();

                    status = false;
                }
                else
                {
                    storageDetails = new StorageDetails(defaultFolderPath);
                    status         = false;
                }
            }
            else
            {
                Directory.CreateDirectory(defaultFolderPath);
                storageDetails = new StorageDetails(defaultFolderPath);
                status         = true;
            }

            UpdateThread updateThread = new UpdateThread(status);
            Thread       thread       = new Thread(new ThreadStart(updateThread.run));

            thread.Start();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Saves an object of StorageDetails to a file
 /// </summary>
 /// <param name="storageDetails">Object of StorageDetails</param>
 public void Save(StorageDetails storageDetails)
 {
     Contract.Requires(storageDetails != null);
     try
     {
         output = new FileStream(FILE_NAME, FileMode.OpenOrCreate, FileAccess.Write);
         formatter.Serialize(output, storageDetails);
     }
     catch (IOException)
     {
         //do nothing
     }
     catch (SerializationException)
     {
         //do nothing
     }
 }