/// <summary> /// Constructs a new instance. /// </summary> /// <param name="context">The <see cref="SimpleMessageBusFileProcessorFactoryContext"/> to use.</param> public SimpleMessageBusFileProcessor(SimpleMessageBusFileProcessorFactoryContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } _options = context.Options; _attribute = context.Attribute; _executor = context.Executor; _logger = context.Logger; //RWM: Use reflection because _attribute.GetRootPath() is internal. var dynMethod = _attribute.GetType().GetMethod("GetRootPath", BindingFlags.NonPublic | BindingFlags.Instance); var attributePath = dynMethod.Invoke(_attribute, null); _filePath = Path.Combine(_options.RootFolder, attributePath.ToString()); var settings = new JsonSerializerSettings { DateFormatHandling = DateFormatHandling.IsoDateFormat, }; _serializer = JsonSerializer.Create(settings); }
public SimpleMessageBusFileTriggerBinding(IOptions <FileSystemOptions> options, ParameterInfo parameter, ILogger logger, ISimpleMessageBusFileProcessorFactory fileProcessorFactory) { _options = options; _parameter = parameter; _logger = logger; _fileProcessorFactory = fileProcessorFactory; _attribute = parameter.GetCustomAttribute <SimpleMessageBusFileTriggerAttribute>(inherit: false); _bindingDataProvider = BindingDataProvider.FromTemplate(_attribute.Path); _bindingContract = CreateBindingContract(); }
public SimpleMessageBusFileListener(IOptions <FileSystemOptions> options, SimpleMessageBusFileTriggerAttribute attribute, ITriggeredFunctionExecutor triggerExecutor, ILogger logger, ISimpleMessageBusFileProcessorFactory fileProcessorFactory) { _options = options ?? throw new ArgumentNullException(nameof(options)); _attribute = attribute ?? throw new ArgumentNullException(nameof(attribute)); _triggerExecutor = triggerExecutor ?? throw new ArgumentNullException(nameof(triggerExecutor)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _fileProcessorFactory = fileProcessorFactory ?? throw new ArgumentNullException(nameof(fileProcessorFactory)); _cancellationTokenSource = new CancellationTokenSource(); if (string.IsNullOrEmpty(_options.Value.RootFolder) || !Directory.Exists(_options.Value.RootFolder)) { throw new InvalidOperationException(string.Format("Path '{0}' is invalid. FilesConfiguration.RootPath must be set to a valid directory location.", _options.Value.RootFolder)); } //RWM: Use reflection because _attribute.GetRootPath() is internal. var dynMethod = _attribute.GetType().GetMethod("GetRootPath", BindingFlags.NonPublic | BindingFlags.Instance); var attributePath = dynMethod.Invoke(_attribute, null); _watchPath = Path.Combine(_options.Value.RootFolder, attributePath.ToString()); }
/// <summary> /// Constructs a new instance /// </summary> /// <param name="options">The <see cref="FilesOptions"/></param> /// <param name="attribute">The <see cref="SimpleMessageBusFileTriggerAttribute"/></param> /// <param name="executor">The function executor.</param> /// <param name="logger">The <see cref="ILogger"/>.</param> public SimpleMessageBusFileProcessorFactoryContext(FileSystemOptions options, SimpleMessageBusFileTriggerAttribute attribute, ITriggeredFunctionExecutor executor, ILogger logger) { Options = options ?? throw new ArgumentNullException(nameof(options)); Attribute = attribute ?? throw new ArgumentNullException(nameof(attribute)); Executor = executor ?? throw new ArgumentNullException(nameof(executor)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); }