Exemplo n.º 1
0
        static TempFileManager()
        {
            var qc = ConfigurationManager.GetSection("TempFileManagerProvider") as TempFileManagerProviderConfiguration;

            if (qc == null || qc.DefaultProvider == null || qc.Providers == null || qc.Providers.Count < 1)
                throw new ProviderException("You must specify a valid default provider for TempFileManagerProvider.");

            //Instantiate the providers
            ProvidersHelper.InstantiateProviders(qc.Providers, providerCollection, typeof (TempFileManagerProviderBase));
            providerCollection.SetReadOnly();
            defaultProvider = providerCollection[qc.DefaultProvider];

            if (defaultProvider != null && defaultProvider.AutoStartPurge && defaultProvider.MaxAgeOfFilesInMinutes > 0)
            {
                try
                {
                    //Create the Timer
                    Log.Debug(typeof (TempFileManager),
                              "Trying to create the Peridic Task to delete Temporary Files");
                    providerTimer.Elapsed += providerTimer_Elapsed;
                    providerTimer.Interval = defaultProvider.MaxAgeOfFilesInMinutes*60*1000;
                    providerTimer.Start();
                }
                catch (Exception ex)
                {
                    throw new ProviderCannotStartThePeriodicPurgeTaskException(
                        "The Periodic Task could not be started.", ex);
                }
                return;
            }
            var defaultProviderProp = qc.ElementInformation.Properties["defaultProvider"];
            if (defaultProviderProp != null)
            {
                throw new ConfigurationErrorsException(
                    "You must specify a default provider for the TempFileManagerProvider.",
                    defaultProviderProp.Source,
                    defaultProviderProp.LineNumber);
            }
        }
 public void CopyTo(TempFileManagerProviderBase[] array, int index)
 {
     base.CopyTo(array, index);
 }