| | 1 | | // Copyright (c) Microsoft. All rights reserved. |
| | 2 | | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| | 3 | |
|
| | 4 | | namespace Microsoft.Azure.EventHubs.Processor |
| | 5 | | { |
| | 6 | | class DefaultEventProcessorFactory<TEventProcessor> : IEventProcessorFactory |
| | 7 | | where TEventProcessor : IEventProcessor, new() |
| | 8 | | { |
| | 9 | | readonly TEventProcessor instance; |
| | 10 | |
|
| 0 | 11 | | public DefaultEventProcessorFactory() |
| | 12 | | { |
| 0 | 13 | | } |
| | 14 | |
|
| 0 | 15 | | public DefaultEventProcessorFactory(TEventProcessor instance) |
| | 16 | | { |
| 0 | 17 | | this.instance = instance; |
| 0 | 18 | | } |
| | 19 | |
|
| | 20 | | public IEventProcessor CreateEventProcessor(PartitionContext context) |
| | 21 | | { |
| 0 | 22 | | if (this.instance == null) |
| | 23 | | { |
| 0 | 24 | | return new TEventProcessor(); |
| | 25 | | } |
| | 26 | |
|
| 0 | 27 | | return this.instance; |
| | 28 | | } |
| | 29 | | } |
| | 30 | | } |