Exemple #1
0
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.AddAppSettingsToConfiguration();

            // Initialise any common services
            CQRSAzureBindings.InitializeServices(builder.Services);

            // Initialise any outbound notifications
            NotificationDispatcherFactory.CreateDispatcher(builder.Services);

            // Initialise any inbound listeners
        }
        public EventStream(EventStreamAttribute attribute,
                           IWriteContext context              = null,
                           IEventStreamSettings settings      = null,
                           INotificationDispatcher dispatcher = null
                           )
        {
            _domainName     = attribute.DomainName;
            _entityTypeName = attribute.EntityTypeName;
            _instanceKey    = attribute.InstanceKey;


            if (null == settings)
            {
                _settings = new EventStreamSettings();
            }
            else
            {
                _settings = settings;
            }

            // wire up the event stream writer
            _writer = _settings.CreateWriterForEventStream(attribute);

            if (null != context)
            {
                _context = context;
                if (null != _writer)
                {
                    _writer.SetContext(_context);
                }
            }

            if (null == dispatcher)
            {
                if (!string.IsNullOrWhiteSpace(attribute.NotificationDispatcherName))
                {
                    _notificationDispatcher = NotificationDispatcherFactory.GetDispatcher(attribute.NotificationDispatcherName);
                }
                else
                {
                    // Create a new dispatcher
                    _notificationDispatcher = NotificationDispatcherFactory.GetDefaultDispatcher();
                }
            }
            else
            {
                _notificationDispatcher = dispatcher;
            }
        }
        /// <summary>
        /// Create the projection from the attribute linked to the function parameter
        /// </summary>
        /// <param name="attribute">
        /// The attribute describing which projection to run
        /// </param>
        public Classification(ClassificationAttribute attribute,
                              IEventStreamSettings settings                = null,
                              INotificationDispatcher dispatcher           = null,
                              IClassificationSnapshotReader snapshotReader = null,
                              IClassificationSnapshotWriter snapshotWriter = null)
        {
            _domainName         = attribute.DomainName;
            _entityTypeName     = attribute.EntityTypeName;
            _instanceKey        = attribute.InstanceKey;
            _classifierTypeName = attribute.ClassifierTypeName;


            if (null == settings)
            {
                _settings = new EventStreamSettings();
            }
            else
            {
                _settings = settings;
            }

            _connectionStringName = _settings.GetConnectionStringName(attribute);

            if (null == _classificationProcessor)
            {
                _classificationProcessor = _settings.CreateClassificationProcessorForEventStream(attribute);
            }

            if (null == dispatcher)
            {
                // Create a new dispatcher
                _notificationDispatcher = NotificationDispatcherFactory.GetDefaultDispatcher();
            }
            else
            {
                _notificationDispatcher = dispatcher;
            }

            if (null != snapshotReader)
            {
                _snapshotReader = snapshotReader;
            }

            if (null != snapshotWriter)
            {
                _snapshotWriter = snapshotWriter;
            }
        }