public ScanStoreRestImpl(String configFileName, CodeLineScanEvent e) { try { CreateScanStoreConfigFileIfNecessary(configFileName, e); string text = System.IO.File.ReadAllText(configFileName); Settings = Newtonsoft.Json.JsonConvert.DeserializeObject <ScanStoreConfig>(text); } catch (FileNotFoundException ex) { throw new ConfigNotFoundException(ex); } }
public ScanStoreApi(String configFileName) { try { String dir = AppDomain.CurrentDomain.BaseDirectory; string text = System.IO.File.ReadAllText(configFileName); Settings = Newtonsoft.Json.JsonConvert.DeserializeObject <ScanStoreConfig>(text); } catch (FileNotFoundException e) { throw new ConfigNotFoundException(e); } }
private void CreateScanStoreConfigFileIfNecessary(String configFileName, CodeLineScanEvent e) { if (!System.IO.File.Exists(configFileName) && Utils.IsConfigurationEvent(e)) { var configData = Utils.ConfigurationData(e); var longUrl = configData.RetrieveLongUrl(); ScanStoreConfig settings = new ScanStoreConfig() { ClientId = configData.ClientId, AccessKey = configData.AccessKey, BaseUrl = longUrl, ProtocolVersion = configData.ProtocolVersion }; settings.Write(configFileName); } }