Esempio n. 1
0
        /// <summary>
        /// Create a new event stream from the attribute passed in
        /// </summary>
        /// <param name="attribute">
        /// The EventStreamAttribute tagging the parameter to crreate by dependency injection
        /// </param>
        /// <param name="context">
        /// The context within which this binding is occuring
        /// </param>
        /// <returns>
        /// A task that can create an event stream when required
        /// </returns>
        public static Task <EventStream> BuildEventStreamFromAttribute(EventStreamAttribute attribute,
                                                                       ValueBindingContext context)
        {
            // If possible get the connection string to use

            // If possible, get the write context to use

            // Use this and the attribute to create a new event stream instance
            return(Task <EventStream> .FromResult(new EventStream(attribute)));
        }
Esempio n. 2
0
        public void MakeQueueName_Inalid_TestMethod()
        {
            string expected = "bank-account";
            string actual   = "not set";

            IEventStreamIdentity target = new EventStreamAttribute("1Bank", "Account-", "J920377-A");

            actual = QueueNotificationDispatcher.MakeQueueName(target);

            Assert.AreEqual(expected, actual);
        }
        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 a new event stream from the attribute passed in
        /// </summary>
        /// <param name="attribute">
        /// The EventStreamAttribute tagging the parameter to crreate by dependency injection
        /// </param>
        /// <param name="context">
        /// The context within which this binding is occuring
        /// </param>
        /// <returns>
        /// A task that can create an event stream when required
        /// </returns>
        public static Task <EventStream> BuildEventStreamFromAttribute(EventStreamAttribute attribute,
                                                                       ValueBindingContext context)
        {
            // If possible get the event stream settings to use

            // If possible, get the write context to use
            IWriteContext writeContext = WriteContext.CreateFunctionContext(context.FunctionContext);

            // If possible, get the notification dipatcher to use
            INotificationDispatcher dispatcher = NotificationDispatcherFactory.NotificationDispatcher;

            // Use this and the attribute to create a new event stream instance
            return(Task <EventStream> .FromResult(new EventStream(attribute,
                                                                  context : writeContext,
                                                                  dispatcher : dispatcher )));
        }
Esempio n. 5
0
        /// <summary>
        /// Turn the parameter (with attribute) into an EventStream object
        /// </summary>
        /// <returns>
        /// A built [EventStream] object
        /// </returns>
        public Task <object> GetValueAsync()
        {
            if (null == _item)
            {
                if (null != _parameter)
                {
                    EventStreamAttribute attribute = _parameter.GetCustomAttribute <EventStreamAttribute>(inherit: false);
                    if (null != attribute)
                    {
                        _item = new EventStream(attribute);
                    }
                }
            }

            return(Task.FromResult <object>(_item));
        }
Esempio n. 6
0
        public async Task <object> GetValueAsync()
        {
            object item = null;

            await ValidateParameter(_parameter);

            if (null != _parameter)
            {
                EventStreamAttribute attribute = _parameter.GetCustomAttribute <EventStreamAttribute>(inherit: false);
                if (null != attribute)
                {
                    item = new EventStream(attribute);
                }
            }

            return(item);
        }
Esempio n. 7
0
        public EventStream(EventStreamAttribute attribute,
                           string connectionStringName = "")
        {
            _domainName           = attribute.DomainName;
            _aggregateTypeName    = attribute.AggregateTypeName;
            _aggregateInstanceKey = attribute.InstanceKey;

            if (string.IsNullOrWhiteSpace(connectionStringName))
            {
                _connectionStringName = ConnectionStringNameAttribute.DefaultConnectionStringName(attribute);
            }
            else
            {
                _connectionStringName = connectionStringName;
            }

            // wire up the event stream writer
            // TODO : Cater for different backing technologies... currently just AppendBlob
            _writer = new CQRSAzure.EventSourcing.Azure.Blob.Untyped.BlobEventStreamWriterUntyped(attribute,
                                                                                                  connectionStringName = _connectionStringName);
        }