/// <summary> /// Add the specified data file to the engine /// </summary> /// <param name="dataFile"></param> /// <exception cref="ArgumentNullException"> /// Thrown if a required parameter is null /// </exception> public override void AddDataFile(IAspectEngineDataFile dataFile) { if (dataFile == null) { throw new ArgumentNullException(nameof(dataFile)); } if (DataFiles.Count > 0) { throw new Exception($"{GetType().Name} already " + "has a configured data source."); } base.AddDataFile(dataFile); // Data files for OnPremise DeviceDetection engines are not // processed by the 'ConfigureEngine' method in // OnPremiseAspectEngineBuilderBase. // This is because they are added in the engine constructor // instead. // Therefore, to avoid unnecessary memory usage, we need to // check for and clear the data stream here instead. if (dataFile.Configuration.DataStream != null) { dataFile.Configuration.DataStream.Dispose(); dataFile.Configuration.DataStream = null; } }
/// <summary> /// Construct a new instance of the Hash engine. /// </summary> /// <param name="loggerFactory">Logger to use</param> /// <param name="deviceDataFactory"> /// Method used to get an aspect data instance /// </param> /// <param name="dataFile">Meta data related to the data file</param> /// <param name="config">Configuration instance</param> /// <param name="properties">Properties to be initialised</param> /// <param name="tempDataFilePath"> /// The directory to use when storing temporary copies of the /// data file(s) used by this engine. /// </param> /// <param name="swigFactory"> /// The factory object to use when creating swig wrapper instances. /// Usually a <see cref="SwigFactory"/> instance. /// Unit tests can override this to mock behaviour as needed. /// </param> internal DeviceDetectionHashEngine( ILoggerFactory loggerFactory, IAspectEngineDataFile dataFile, IConfigSwigWrapper config, IRequiredPropertiesConfigSwigWrapper properties, Func <IPipeline, FlowElementBase <IDeviceDataHash, IFiftyOneAspectPropertyMetaData>, IDeviceDataHash> deviceDataFactory, string tempDataFilePath, ISwigFactory swigFactory) : base( loggerFactory.CreateLogger <DeviceDetectionHashEngine>(), deviceDataFactory, tempDataFilePath) { _config = config; _propertiesConfigSwig = properties; _swigFactory = swigFactory; AddDataFile(dataFile); }
/// <summary> /// Add the specified data file to the engine. /// </summary> /// <param name="dataFile"> /// The data file to add. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if supplied data file is null. /// </exception> public virtual void AddDataFile(IAspectEngineDataFile dataFile) { if (dataFile == null) { throw new ArgumentNullException(nameof(dataFile)); } if (_dataFiles.Any(f => f.Identifier == dataFile.Identifier) == false) { dataFile.Engine = this; _dataFiles.Add(dataFile); } if (dataFile.Configuration.DataStream != null) { // The DataStream has been set so call the relevant overload // to be clear about our intent. RefreshData(dataFile.Identifier, dataFile.Configuration.DataStream); } else { RefreshData(dataFile.Identifier); } }
/// <summary> /// Get the URL to call to request an updated version of the /// supplied data file. /// </summary> /// <param name="dataFile"> /// The data file to build an update URL for. /// </param> /// <returns> /// The URL to call in order to check for and download an update. /// </returns> /// <exception cref="ArgumentNullException"> /// Thrown if the supplied data file is null /// </exception> public Uri GetFormattedDataUpdateUri(IAspectEngineDataFile dataFile) { if (dataFile == null) { throw new ArgumentNullException(nameof(dataFile)); } var fiftyOneDataFile = dataFile as IFiftyOneDataFile; if (fiftyOneDataFile != null) { string[] parameters = new string[] { "LicenseKeys=" + String.Join("|", dataFile.Configuration.DataUpdateLicenseKeys), "Download=True", "Type=" + fiftyOneDataFile.DataDownloadType, }; return(new Uri($"{dataFile.Configuration.DataUpdateUrl}?{string.Join("&", parameters)}")); } else { return(new Uri(dataFile.Configuration.DataUpdateUrl)); } }
public string GetFormattedDataUpdateUrl(IAspectEngineDataFile dataFile) { return(null); }
public Uri GetFormattedDataUpdateUri(IAspectEngineDataFile dataFile) { return(null); }
#pragma warning disable CA1055 // Uri return values should not be strings public string GetFormattedDataUpdateUrl(IAspectEngineDataFile dataFile) #pragma warning restore CA1055 // Uri return values should not be strings { return(GetFormattedDataUpdateUri(dataFile).AbsoluteUri); }