Example #1
0
        public EventStream(EventStreamAttribute attribute,
                           string connectionStringName = "",
                           IWriteContext context       = null)
        {
            _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);

            if (null != context)
            {
                _context = context;
                if (null != _writer)
                {
                    _writer.SetContext(_context);
                }
            }
        }
Example #2
0
        public EntityType(string entityTypeName,
                          string domainParentName     = @"",
                          string connectionStringName = @"",
                          string storageType          = @"BlobStream",
                          ProjectionDefinitions projectionDefinitions = null,
                          ClassifierDefinitions classifierDefinitions = null,
                          EventTypes eventTypes = null,
                          IdentifierGroupDefinitions identifierGroupDefinitions = null)
        {
            _entityTypeName = entityTypeName;
            if (!string.IsNullOrWhiteSpace(connectionStringName))
            {
                _connectionStringName = connectionStringName;
            }
            else
            {
                // make a default connection string to use
                _connectionStringName = ConnectionStringNameAttribute.DefaultConnectionStringName(domainParentName, entityTypeName);
            }
            if (!string.IsNullOrWhiteSpace(storageType))
            {
                _storageType = storageType;
            }

            if (null == projectionDefinitions)
            {
                _projectionDefinitions = new ProjectionDefinitions();
            }
            else
            {
                _projectionDefinitions = projectionDefinitions;
            }

            if (null == classifierDefinitions)
            {
                _classifierDefinitions = new ClassifierDefinitions();
            }
            else
            {
                _classifierDefinitions = classifierDefinitions;
            }

            if (null == eventTypes)
            {
                _eventTypes = new EventTypes();
            }
            else
            {
                _eventTypes = eventTypes;
            }

            if (null == identifierGroupDefinitions)
            {
                _identifierGroupDefinitions = new IdentifierGroupDefinitions();
            }
            else
            {
                _identifierGroupDefinitions = identifierGroupDefinitions;
            }
        }
Example #3
0
        /// <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 Projection(ProjectionAttribute attribute,
                          string connectionStringName = "")
        {
            _domainName           = attribute.DomainName;
            _aggregateTypeName    = attribute.AggregateTypeName;
            _aggregateInstanceKey = attribute.InstanceKey;
            _projectionTypeName   = attribute.ProjectionTypeName;


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

            if (null == _projectionProcessor)
            {
                // TODO : Allow for different backing technologies... currently just AppendBlob
                _projectionProcessor = CQRSAzure.EventSourcing.Azure.Blob.Untyped.BlobEventStreamReaderUntyped.CreateProjectionProcessor(attribute,
                                                                                                                                         ConnectionStringNameAttribute.DefaultBlobStreamSettings(_domainName, _aggregateTypeName));
            }
        }
Example #4
0
        public void DomainNameAttribute_EnvironmentVariables_QueryExactMatch_Test()
        {
            string expected = "QueryTestStorageConnectionString";
            string actual   = "Not set";


            actual = ConnectionStringNameAttribute.DefaultConnectionStringName("Query", "test type");

            Assert.AreEqual(expected, actual);
        }
Example #5
0
 public string GetConnectionStringName(IEventStreamIdentity attribute)
 {
     CreateFronEnvironmentStringIfNotExists(attribute);
     if (AllSettings.ContainsKey(EventStreamSetting.MakeDomainQualifiedEntityName(attribute)))
     {
         return(AllSettings[EventStreamSetting.MakeDomainQualifiedEntityName(attribute)].ConnectionStringName);
     }
     else
     {
         return(ConnectionStringNameAttribute.DefaultConnectionStringName(attribute));
     }
 }
Example #6
0
        private static SignalRAttribute SignalRAttributeFromTarget(string target)
        {
            if (!string.IsNullOrWhiteSpace(target))
            {
                SignalRAttribute ret = new SignalRAttribute()
                {
                    // Look up the connection string from the hub name
                    ConnectionStringSetting = ConnectionStringNameAttribute.DefaultConnectionStringName(Constants.Domain_Query, target),
                    HubName = target
                };
                return(ret);
            }

            return(null);
        }
        private static SignalRAttribute SignalRAttributeFromTarget(string hookAddress)
        {
            if (!string.IsNullOrWhiteSpace(hookAddress))
            {
                SignalRAttribute ret = new SignalRAttribute()
                {
                    // Look up the connection string from the hub name
                    ConnectionStringSetting = ConnectionStringNameAttribute.DefaultConnectionStringName(Constants.Domain_Command, hookAddress),
                    HubName = hookAddress
                };
                return(ret);
            }

            return(null);
        }
        public IdentifierGroup(IdentifierGroupAttribute identifierGroup,
                               string connectionStringName = @"")
        {
            _domainName          = identifierGroup.DomainName;
            _aggregateTypeName   = identifierGroup.AggregateTypeName;
            _identifierGroupName = identifierGroup.IdentifierGroupName;

            if (string.IsNullOrWhiteSpace(connectionStringName))
            {
                _connectionStringName = ConnectionStringNameAttribute.DefaultConnectionStringName(identifierGroup.DomainName, identifierGroup.AggregateTypeName);
            }
            else
            {
                _connectionStringName = connectionStringName;
            }
        }
        /// <summary>
        /// Create the classifier from the attribute assigned to it in the function
        /// parameters
        /// </summary>
        /// <param name="attribute">
        /// The attribute that describes the classifier to use
        /// </param>
        public Classifier(ClassifierAttribute attribute,
                          string connectionStringName = @"")
        {
            _domainName           = attribute.DomainName;
            _aggregateTypeName    = attribute.AggregateTypeName;
            _aggregateInstanceKey = attribute.InstanceKey;
            _classifierTypeName   = attribute.ClassifierTypeName;

            if (string.IsNullOrWhiteSpace(connectionStringName))
            {
                _connectionStringName = ConnectionStringNameAttribute.DefaultConnectionStringName(attribute);
            }
            else
            {
                _connectionStringName = connectionStringName;
            }
        }
Example #10
0
        public static EventStreamSetting SettingsFromEnvironmentStringValue(IEventStreamIdentity eventStreamIdentity,
                                                                            string environmentStringValue)
        {
            EventStreamSetting ret = new EventStreamSetting(MakeDomainQualifiedEntityName(eventStreamIdentity));

            if (!string.IsNullOrWhiteSpace(environmentStringValue))
            {
                if (environmentStringValue.StartsWith("Table;"))
                {
                    ret.Storage = EVENTSTREAMIMPLEMENTATIOIN_TABLE;
                    if (environmentStringValue.Length > @"Table;".Length)
                    {
                        ret.ConnectionStringName = environmentStringValue.Substring(6);
                    }
                }
                if (environmentStringValue.StartsWith("AppendBlob;"))
                {
                    ret.Storage = EVENTSTREAMIMPLEMENTATION_APPENDBLOB;
                    if (environmentStringValue.Length > @"AppendBlob;".Length)
                    {
                        ret.ConnectionStringName = environmentStringValue.Substring(11);
                    }
                }
            }
            // If not able to make a setting from the environment string, fall back on the default
            if (string.IsNullOrWhiteSpace(ret.Storage))
            {
                // Default  to event blob storage
                ret.Storage = EVENTSTREAMIMPLEMENTATION_APPENDBLOB;
            }
            if (string.IsNullOrWhiteSpace(ret.ConnectionStringName))
            {
                ret.ConnectionStringName = ConnectionStringNameAttribute.DefaultConnectionStringName(eventStreamIdentity);
            }

            return(ret);
        }
Example #11
0
        public void DomainNameAttribute_EnvironmentVariables_Test()
        {
            string expected = ConnectionStringNameAttribute.DefaultConnectionStringName("Test", "test type");

            Assert.IsNotEmpty(expected, "No default connection");
        }