public void WriteToUserProfile() { StorageEmulatorUpdatableConfiguration.cachedConfig = this; using (FileStream fileStream = File.Create(StorageEmulatorUpdatableConfiguration.GetConfigFilePath())) { (new XmlSerializer(typeof(StorageEmulatorUpdatableConfiguration))).Serialize(fileStream, this); } }
public static bool GetLoggingEnabled() { StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration; if (!StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(out storageEmulatorUpdatableConfiguration)) { storageEmulatorUpdatableConfiguration = new StorageEmulatorUpdatableConfiguration(); } return(storageEmulatorUpdatableConfiguration.LoggingEnabled); }
public static string GetMasterConnectionString() { string sqlInstance = "localhost\\SQLExpress"; StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration = null; if (StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(out storageEmulatorUpdatableConfiguration)) { sqlInstance = storageEmulatorUpdatableConfiguration.SqlInstance; } return(string.Format("Server={0};Integrated security=SSPI;database=master", sqlInstance)); }
static StorageEmulatorConfigCache() { object configurationSection = StorageEmulatorUpdatableConfiguration.GetConfigurationSection("StorageEmulatorConfig"); StorageEmulatorConfigCache.Configuration = configurationSection as StorageEmulatorConfig; if (StorageEmulatorConfigCache.Configuration == null) { string rawXml = ((DefaultSection)configurationSection).SectionInformation.GetRawXml(); StorageEmulatorConfigCache.Configuration = StorageEmulatorConfigurationHandler.FromString(rawXml); } }
public static string GetLogPath() { StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration; if (!StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(out storageEmulatorUpdatableConfiguration)) { storageEmulatorUpdatableConfiguration = new StorageEmulatorUpdatableConfiguration(); } if (!Directory.Exists(storageEmulatorUpdatableConfiguration.LogPath)) { Directory.CreateDirectory(storageEmulatorUpdatableConfiguration.LogPath); } return(storageEmulatorUpdatableConfiguration.LogPath); }
public static string GetStorageEmulatorDBConnectionString() { string sqlInstance = null; StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration = null; if (StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(out storageEmulatorUpdatableConfiguration)) { sqlInstance = storageEmulatorUpdatableConfiguration.SqlInstance; } string database = null; using (SqlConnection sqlConnection = new SqlConnection(StorageEmulatorUpdatableConfiguration.GetDbConnectionString())) { if (sqlInstance == null) { sqlInstance = sqlConnection.DataSource; } database = sqlConnection.Database; } return(string.Format("Server={0};Integrated security=SSPI;database={1}", sqlInstance, database)); }
public static string GetSqlInstance() { string sqlInstance = null; StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration = null; if (StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(out storageEmulatorUpdatableConfiguration)) { sqlInstance = storageEmulatorUpdatableConfiguration.SqlInstance; } if (sqlInstance == null) { using (SqlConnection sqlConnection = new SqlConnection(StorageEmulatorUpdatableConfiguration.GetDbConnectionString())) { if (sqlInstance == null) { sqlInstance = sqlConnection.DataSource; } } } return(sqlInstance); }
public static bool TryGetFromUserProfile(bool forceRefresh, out StorageEmulatorUpdatableConfiguration result) { result = null; if (!forceRefresh && StorageEmulatorUpdatableConfiguration.cachedConfig != null) { result = StorageEmulatorUpdatableConfiguration.cachedConfig; return(true); } string configFilePath = StorageEmulatorUpdatableConfiguration.GetConfigFilePath(); if (!File.Exists(configFilePath)) { return(false); } FileStream fileStream = File.OpenRead(configFilePath); StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration = (StorageEmulatorUpdatableConfiguration)(new XmlSerializer(typeof(StorageEmulatorUpdatableConfiguration))).Deserialize(fileStream); fileStream.Close(); StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration1 = storageEmulatorUpdatableConfiguration; StorageEmulatorUpdatableConfiguration.cachedConfig = storageEmulatorUpdatableConfiguration1; result = storageEmulatorUpdatableConfiguration1; return(true); }
public static bool TryGetFromUserProfile(out StorageEmulatorUpdatableConfiguration result) { return(StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(false, out result)); }