コード例 #1
0
ファイル: VirtualStream.cs プロジェクト: zerojuls/cms-3
        private static void Configure()
        {
            lock (configurationLockObject)
            {
                if (!configured)
                {
                    var maximumSize = defaultBufferMaximumSize;
                    var blockSize   = defaultBufferBlockSize;
                    var path        = TemporaryDataStorage.defaultPath;

                    if (maximumSize < blockSize || maximumSize % blockSize != 0)
                    {
                        maximumSize = defaultBufferMaximumSize;
                        blockSize   = defaultBufferBlockSize;
                    }

                    defaultBufferMaximumSize = maximumSize;
                    defaultBufferBlockSize   = blockSize;

                    var defaultPath = Path.GetTempPath();

                    if (path != null)
                    {
                        path = ValidatePath(path);
                    }

                    if (path == null)
                    {
                        path = defaultPath;
                    }

                    TempFileStream.SetTemporaryPath(path);

                    configured = true;
                }
            }
        }
コード例 #2
0
 // Token: 0x06000C41 RID: 3137 RVA: 0x0006C1C4 File Offset: 0x0006A3C4
 private static void Configure()
 {
     if (TemporaryDataStorage.Configured)
     {
         return;
     }
     lock (TemporaryDataStorage.configurationLockObject)
     {
         if (!TemporaryDataStorage.Configured)
         {
             int    num  = TemporaryDataStorage.DefaultBufferMaximumSize;
             int    num2 = TemporaryDataStorage.DefaultBufferBlockSize;
             string text = TemporaryDataStorage.DefaultPath;
             IList <CtsConfigurationSetting> configuration = ApplicationServices.Provider.GetConfiguration(null);
             foreach (CtsConfigurationSetting ctsConfigurationSetting in configuration)
             {
                 if (ctsConfigurationSetting.Name.Equals("TemporaryStorage", StringComparison.OrdinalIgnoreCase))
                 {
                     foreach (CtsConfigurationArgument ctsConfigurationArgument in ctsConfigurationSetting.Arguments)
                     {
                         if (ctsConfigurationArgument.Name.Equals("Path", StringComparison.OrdinalIgnoreCase))
                         {
                             text = ctsConfigurationArgument.Value.Trim();
                         }
                         else if (ctsConfigurationArgument.Name.Equals("MaximumBufferSize", StringComparison.OrdinalIgnoreCase))
                         {
                             if (!int.TryParse(ctsConfigurationArgument.Value.Trim(), out num))
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num = TemporaryDataStorage.DefaultBufferMaximumSize;
                             }
                             else if (num < 16 || num > 10240)
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num = TemporaryDataStorage.DefaultBufferMaximumSize;
                             }
                             else
                             {
                                 num *= 1024;
                             }
                         }
                         else if (ctsConfigurationArgument.Name.Equals("BufferIncrement", StringComparison.OrdinalIgnoreCase))
                         {
                             if (!int.TryParse(ctsConfigurationArgument.Value.Trim(), out num2))
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num2 = TemporaryDataStorage.DefaultBufferBlockSize;
                             }
                             else if (num2 < 4 || num2 > 64)
                             {
                                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                                 num2 = TemporaryDataStorage.DefaultBufferBlockSize;
                             }
                             else
                             {
                                 num2 *= 1024;
                             }
                         }
                         else
                         {
                             ApplicationServices.Provider.LogConfigurationErrorEvent();
                         }
                     }
                 }
             }
             if (num < num2 || num % num2 != 0)
             {
                 ApplicationServices.Provider.LogConfigurationErrorEvent();
                 num  = TemporaryDataStorage.DefaultBufferMaximumSize;
                 num2 = TemporaryDataStorage.DefaultBufferBlockSize;
             }
             TemporaryDataStorage.DefaultBufferMaximumSize = num;
             TemporaryDataStorage.DefaultBufferBlockSize   = num2;
             string systemTempPath = TemporaryDataStorage.GetSystemTempPath();
             if (text != null)
             {
                 text = TemporaryDataStorage.ValidatePath(text);
             }
             if (text == null)
             {
                 text = systemTempPath;
             }
             TempFileStream.SetTemporaryPath(text);
             TemporaryDataStorage.Configured = true;
         }
     }
 }