Exemplo n.º 1
0
        /// <summary>
        /// Use a 51Degrees on-premise device detection engine to
        /// perform device detection.
        /// </summary>
        /// <param name="dataStream">
        /// The device detection data file as a <see cref="Stream"/>.
        /// </param>
        /// <param name="algorithm">
        /// The detection algorithm that the supplied data supports.
        /// </param>
        /// <param name="key">
        /// The license key to use when checking for updates to the
        /// data file.
        /// A license key can be obtained from the
        /// [51Degrees website](https://51degrees.com/pricing).
        /// If you have no license key then this parameter can be
        /// set to null, but doing so will disable automatic updates.
        /// </param>
        /// <returns>
        /// A builder that can be used to configure and build a pipeline
        /// that will use the on-premise detection engine.
        /// </returns>
        /// <seealso cref="UseOnPremise(string, string, bool)"/>
        public DeviceDetectionOnPremisePipelineBuilder UseOnPremise(
            Stream dataStream, DeviceDetectionAlgorithm algorithm, string key)
        {
            var builder = new DeviceDetectionOnPremisePipelineBuilder(
                _loggerFactory, _dataUpdateService, _httpClient);

            builder.SetEngineData(dataStream, algorithm, key);
            return(builder);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Set the byte array to use as a data source when
 /// creating the engine.
 /// </summary>
 /// <param name="dataStream">
 /// The entire device detection data file as a <see cref="Stream"/>.
 /// </param>
 /// <param name="algorithm">
 /// The detection algorithm that the supplied data supports.
 /// </param>
 /// <param name="key">
 /// The license key to use when checking for updates to the
 /// data file.
 /// This parameter can be set to null, but doing so will disable
 /// automatic updates.
 /// </param>
 /// <returns>
 /// This builder instance.
 /// </returns>
 internal DeviceDetectionOnPremisePipelineBuilder SetEngineData(
     Stream dataStream,
     DeviceDetectionAlgorithm algorithm,
     string key)
 {
     _engineDataStream     = dataStream;
     _algorithm            = algorithm;
     _dataUpdateLicenseKey = key;
     return(this);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Set the filename of the device detection data file that the
 /// engine should use.
 /// </summary>
 /// <param name="filename">
 /// The data file
 /// </param>
 /// <param name="key">
 /// The license key to use when checking for updates to the
 /// data file.
 /// This parameter can be set to null, but doing so will disable
 /// automatic updates.
 /// </param>
 /// <param name="createTempDataCopy">
 /// True to create a temporary copy of the data file when
 /// the engine is built.
 /// This is required in order for automatic updates
 /// to work correctly.
 /// </param>
 /// <returns>
 /// This builder instance.
 /// </returns>
 /// <exception cref="PipelineConfigurationException">
 /// Thrown if the filename has an unknown extension.
 /// </exception>
 internal DeviceDetectionOnPremisePipelineBuilder SetFilename(
     string filename,
     string key,
     bool createTempDataCopy = true)
 {
     _filename             = filename;
     _createTempDataCopy   = createTempDataCopy;
     _dataUpdateLicenseKey = key;
     if (filename.EndsWith(".hash", StringComparison.OrdinalIgnoreCase))
     {
         _algorithm = DeviceDetectionAlgorithm.Hash;
     }
     else
     {
         throw new PipelineConfigurationException(
                   string.Format(CultureInfo.InvariantCulture,
                                 Messages.ExceptionUnrecognizedFileExtension,
                                 filename));
     }
     return(this);
 }
Exemplo n.º 4
0
 internal DeviceDetectionOnPremisePipelineBuilder SetEngineData(Stream dataStream, DeviceDetectionAlgorithm algorithm)
 {
     _engineDataStream = dataStream;
     _algorithm        = algorithm;
     return(this);
 }