/// <summary>
        /// Called by the 'BuildEngine' method to handle
        /// creation of the engine instance.
        /// </summary>
        /// <param name="properties"></param>
        /// <returns>
        /// An <see cref="IAspectEngine"/>.
        /// </returns>
        protected override DeviceDetectionHashEngine NewEngine(
            List <string> properties)
        {
            if (DataFiles.Count != 1)
            {
                throw new PipelineConfigurationException(
                          "This builder requires one and only one configured file " +
                          $"but it has {DataFileConfigs.Count}");
            }
            var dataFile = DataFiles.First();

            // We remove the data file configuration from the list.
            // This is because the on-premise engine builder base class
            // adds all the data file configs after engine creation.
            // However, the device detection data files are supplied
            // directly to the constructor.
            // Consequently, we remove it here to stop it from being added
            // again by the base class.
            DataFiles.Remove(dataFile);

            // Update the swig configuration object.
            SwigConfig.setUseUpperPrefixHeaders(false);
            if (dataFile.Configuration.CreateTempCopy && String.IsNullOrEmpty(TempDir) == false)
            {
                using (var tempDirs = new VectorStringSwig())
                {
                    tempDirs.Add(TempDir);
                    SwigConfig.setTempDirectories(tempDirs);
                }
                SwigConfig.setUseTempFile(true);
            }

            // Create swig property configuration object.
            IRequiredPropertiesConfigSwigWrapper propertyConfig = null;

            using (var vProperties = new VectorStringSwig(properties)) {
                propertyConfig = SwigFactory.CreateRequiredProperties(vProperties);
            }

            return(new DeviceDetectionHashEngine(
                       _loggerFactory,
                       dataFile,
                       SwigConfig,
                       propertyConfig,
                       CreateAspectData,
                       TempDir,
                       SwigFactory));
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
 public IEngineSwigWrapper CreateEngine(string fileName,
                                        IConfigSwigWrapper config,
                                        IRequiredPropertiesConfigSwigWrapper requiredProperties)
 {
     return(EngineFromFile(fileName, config, requiredProperties));
 }
コード例 #4
0
 public IEngineSwigWrapper CreateEngine(byte[] data, int dataSize,
                                        IConfigSwigWrapper config,
                                        IRequiredPropertiesConfigSwigWrapper requiredProperties)
 {
     return(EngineFromData(data, dataSize, config, requiredProperties));
 }