Esempio n. 1
0
        public JsonDataContext()
        {
            this.directoryHelper = new DirectoryHelper();
            location             = @"C:\Users\pgathany\Desktop\Personal\Json";
            if (!directoryHelper.Exists(location))
            {
                directoryHelper.CreateDirectory(location);
            }
            this.dbLocation = location + @"\" + typeof(T).Name + ".json";
            if (!File.Exists(dbLocation))
            {
                File.Create(dbLocation).Close();
            }

            using (StreamReader r = new StreamReader(dbLocation))
            {
                string json = r.ReadToEnd();
                items = JsonConvert.DeserializeObject <List <T> >(json);
            }
            if (items == null)
            {
                items = new List <T>();
            }
            if (items.Any())
            {
                NextID = items.Select(b => (b as Entity).ID).Max() + 1;
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Cleans up coverage report directory
 /// </summary>
 private void CleanupReportDirectory()
 {
     try
     {
         if (_directoryHelper.Exists(_reportDirectory))
         {
             _directoryHelper.Delete(_reportDirectory, true);
             _eqtTrace.Verbose("{0}: Deleted report directory: '{1}'", CoverletConstants.DataCollectorName, _reportDirectory);
         }
     }
     catch (Exception ex)
     {
         string errorMessage = string.Format(Resources.FailedToCleanupReportDirectory, CoverletConstants.DataCollectorName, _reportDirectory);
         throw new CoverletDataCollectorException(errorMessage, ex);
     }
 }