コード例 #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));
 }