Esempio n. 1
0
        /// <summary>
        /// Initializes static members of the BlobBasedDataContainer class
        /// </summary>
        static BlobBasedDataContainer()
        {
            AppDomain.CurrentDomain.AssemblyResolve += ResolveHandler;

            ServicePointManager.DefaultConnectionLimit = ServicePointManagerConnectionLimit;
            ServicePointManager.Expect100Continue      = false;
            ServicePointManager.UseNagleAlgorithm      = false;

            ExeConfigurationFileMap map = new ExeConfigurationFileMap();

            map.ExeConfigFilename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            Configuration config = null;

            RetryManager.RetryOnceAsync(
                () => config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None),
                TimeSpan.FromSeconds(1),
                ex => ex is ConfigurationErrorsException)
            .GetAwaiter()
            .GetResult();
            Debug.Assert(config != null, "Configuration is not opened properly.");
            DataContainerConfiguration dataProviderConfig = DataContainerConfiguration.GetSection(config);

            downloadBlobThreadCount         = dataProviderConfig.DownloadBlobThreadCount;
            downloadBlobMinBackoffInSeconds = dataProviderConfig.DownloadBlobMinBackOffInSeconds;
            downloadBlobMaxBackoffInSeconds = dataProviderConfig.DownloadBlobMaxBackOffInSeconds;
            downloadBlobRetryCount          = dataProviderConfig.DownloadBlobRetryCount;
            downloadBlobTimeoutInSeconds    = dataProviderConfig.DownloadBlobTimeoutInSeconds;

            TraceHelper.TraceSource.TraceEvent(
                TraceEventType.Information,
                0,
                "[BlobDataContainer] .static constructor: downloadBlobThreadCount={0}, downloadBlobMinBackoffInSeconds={1}, downloadBlobMaxBackoffInSeconds={2}, downloadBlobRetryCount={3}, downloadBlobTimeoutInSeconds={4}",
                downloadBlobThreadCount,
                downloadBlobMinBackoffInSeconds,
                downloadBlobMaxBackoffInSeconds,
                downloadBlobRetryCount,
                downloadBlobTimeoutInSeconds);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes static members of the FileDataContainer class
        /// </summary>
        static FileDataContainer()
        {
            ExeConfigurationFileMap map = new ExeConfigurationFileMap();

            map.ExeConfigFilename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
            Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
            DataContainerConfiguration dataProviderConfig = DataContainerConfiguration.GetSection(config);

            bufferSize = dataProviderConfig.FileShareBufferSizeInKiloBytes * 1024;

            try
            {
                using (RegistryKey key = Registry.LocalMachine.OpenSubKey(smb2ClientFileNotFoundCacheRegistryKey))
                {
                    int fileNotFoundCacheLifetime = (int)key.GetValue(smb2ClientFileNotFoundCacheRegistryName, DefaultSMB2ClientFileNotFoundCacheLifetime);
                    isSMB2ClientFileNotFoundCacheDisabled = fileNotFoundCacheLifetime == 0;
                }
            }
            catch (Exception e)
            {
                TraceHelper.TraceSource.TraceEvent(TraceEventType.Error, 0, "[FileDataContainer] .Static constructor: received exception = {0}", e);
            }
        }