C# Class FiftyOne.Foundation.Mobile.Detection.AutoUpdate

Used to fetch new device data from 51Degrees.mobi if a premium licence has been installed.
Afficher le fichier Open project: 51Degrees/dotNET-Device-Detection Class Usage Examples

Private Properties

Свойство Type Description
ActivateDownloadedFile AutoUpdateStatus
CheckForUpdate void
CheckedDownloadedFileMD5 AutoUpdateStatus
Decompress AutoUpdateStatus
Download AutoUpdateStatus
Download LicenceKeyResults
DownloadFile AutoUpdateStatus
FullUrl System.Uri
GetLastModified System.DateTime
GetMd5Hash string
GetMd5Hash string
GetTempFileName System.IO.FileInfo
GetValidKeys List
ValidateDownloadedFile AutoUpdateStatus

Méthodes publiques

Méthode Description
Update ( IList licenseKeys, FileInfo dataFile ) : AutoUpdateStatus

Uses the given license keys to perform a device data update, writing the data to the file system and filling providers from this factory instance with it.

Update ( string licenseKey, FileInfo dataFile ) : AutoUpdateStatus

Uses the given license key to perform a device data update, writing the data to the file system and filling providers from this factory instance with it.

Private Methods

Méthode Description
ActivateDownloadedFile ( WebClient client, FileInfo binaryFile, FileInfo uncompressedTempFile ) : AutoUpdateStatus

Method represents the final stage of the auto update process. The uncompressed file is swapped in place of the existing master file.

CheckForUpdate ( object state ) : void

Checks if a new data file is available for download and if it is newer than the current data on disk, if enough time has passed between now and the write time of the current data in memory. See Constants.AutoUpdateWait. This method is designed to be used in a seperate thread from the one performing detection.

CheckedDownloadedFileMD5 ( WebClient client, FileInfo compressedTempFile ) : AutoUpdateStatus

Verifies that the data has been downloaded correctly by comparing an MD5 hash off the downloaded data with one taken before the data was sent, which is stored in a response header.

Decompress ( FileInfo sourcePath, FileInfo destinationPath ) : AutoUpdateStatus

Reads a source GZip file and writes the uncompressed data to destination file.

Download ( IList licenceKeys, FileInfo binaryFile ) : AutoUpdateStatus

Downloads and updates the premium data file.

Download ( string licenseKeys ) : LicenceKeyResults

Uses the given license key to perform a device data update, writing the data to the file system and filling providers from this factory instance with it.

DownloadFile ( FileInfo binaryFile, FileInfo compressedTempFile, WebClient client, Uri fullUrl ) : AutoUpdateStatus

Method performs the actual download by setting up and sending request and processing the response.

FullUrl ( IList licenseKeys ) : Uri

Constructs the URL needed to download Enhanced device data.

GetLastModified ( WebClient client ) : System.DateTime

Returns the last modified date from the HTTP response.

GetMd5Hash ( FileInfo file ) : string

Calculates the MD5 hash of the given data array.

GetMd5Hash ( MD5 md5Hash, Stream stream ) : string

Calculates the MD5 hash of the given data array.

GetTempFileName ( FileInfo dataFile ) : FileInfo

Method initialises path to the a temporary file used during the auto update process.

The original data file does not have to exist, but the directory provided must exist and the path should not be a directory.

GetValidKeys ( IList licenseKeys ) : List

Validate the supplied keys to exclude keys from 3rd party products from being used.

ValidateDownloadedFile ( FileInfo binaryFile, FileInfo decompressedTempFile ) : AutoUpdateStatus

Method compares the downloaded data file to the existing data file to check if the update is required. This will prevent file switching if the data file was downloaded but is not newer than the existing data file.

The following conditions must be met for the data file to be considered newer than the current master data file: 1. Current master data file does not exist. 2. If the published dates are not the same. 3. If the number of properties is not the same.

Method Details

Update() public static méthode

Uses the given license keys to perform a device data update, writing the data to the file system and filling providers from this factory instance with it.
public static Update ( IList licenseKeys, FileInfo dataFile ) : AutoUpdateStatus
licenseKeys IList /// The licence keys to use for the update request. ///
dataFile System.IO.FileInfo /// Location of the data file to update or create. ///
Résultat AutoUpdateStatus

Update() public static méthode

Uses the given license key to perform a device data update, writing the data to the file system and filling providers from this factory instance with it.
public static Update ( string licenseKey, FileInfo dataFile ) : AutoUpdateStatus
licenseKey string /// The licence key to use for the update request. ///
dataFile System.IO.FileInfo /// Location of the data file to update or create. ///
Résultat AutoUpdateStatus