FiftyOne.Foundation.Mobile.Detection.WebProvider.Refresh C# (CSharp) Method

Refresh() public static method

Forces the application to reload the active provider on the next request.
public static Refresh ( ) : void
return void
        public static void Refresh()
        {
            var provider = _activeProvider;
            _activeProvider = null;
            _activeProviderCreated = false;
            if (provider != null)
            {
                // Dispose of the old provider.
                provider.Dispose();
            }
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Activates the data array containing the premium data.
        /// </summary>
        /// <param name="data">Data to activate</param>
        public static LicenceKeyResults Activate(byte[] data)
        {
            try
            {
                DataSet dataSet = null;

                // Validate the data provided is correct.
                try
                {
                    dataSet = StreamFactory.Create(data);
                }
                catch (MobileException ex)
                {
                    EventLog.Warn(ex);
                    return(LicenceKeyResults.DataInvalid);
                }

                // Check the configuration.
                try
                {
                    CheckConfig();
                }
                catch (Exception ex)
                {
                    EventLog.Warn(ex);
                    return(LicenceKeyResults.Config);
                }

                // Write the file to the binary data path.
                try
                {
                    File.WriteAllBytes(Detection.Configuration.Manager.BinaryFilePath, data);
                    File.SetLastAccessTimeUtc(Detection.Configuration.Manager.BinaryFilePath, dataSet.Published);
                }
                catch (IOException ex)
                {
                    EventLog.Warn(ex);
                    return(LicenceKeyResults.WriteDataFile);
                }

                // Switch in the new data to complete activation.
                WebProvider.Refresh();

                EventLog.Info(String.Format(
                                  "Activated binary data file '{0}' with new version " +
                                  "dated the '{1:d}'.",
                                  AutoUpdate.MasterBinaryDataFile.FullName,
                                  dataSet.Published));
            }
            catch (Exception ex)
            {
                EventLog.Warn(ex);
                return(LicenceKeyResults.GenericFailure);
            }

            return(LicenceKeyResults.Success);
        }
All Usage Examples Of FiftyOne.Foundation.Mobile.Detection.WebProvider::Refresh