Пример #1
0
 public void WriteToUserProfile()
 {
     StorageEmulatorUpdatableConfiguration.cachedConfig = this;
     using (FileStream fileStream = File.Create(StorageEmulatorUpdatableConfiguration.GetConfigFilePath()))
     {
         (new XmlSerializer(typeof(StorageEmulatorUpdatableConfiguration))).Serialize(fileStream, this);
     }
 }
Пример #2
0
        public static bool GetLoggingEnabled()
        {
            StorageEmulatorUpdatableConfiguration storageEmulatorUpdatableConfiguration;

            if (!StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(out storageEmulatorUpdatableConfiguration))
            {
                storageEmulatorUpdatableConfiguration = new StorageEmulatorUpdatableConfiguration();
            }
            return(storageEmulatorUpdatableConfiguration.LoggingEnabled);
        }
Пример #3
0
        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));
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        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));
        }
Пример #7
0
        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);
        }
Пример #8
0
        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);
        }
Пример #9
0
 public static bool TryGetFromUserProfile(out StorageEmulatorUpdatableConfiguration result)
 {
     return(StorageEmulatorUpdatableConfiguration.TryGetFromUserProfile(false, out result));
 }