void SetupTypeSubscriptions(Type type, ExchangeDataCollection exchangeDataCollection)
        {
            if (type == typeof(object) || IsTypeTopologyKnownConfigured(type))
            {
                return;
            }

            var typeToProcess = type;

            exchangeDataCollection.DeclareExchange(ExchangeName(typeToProcess));

            exchangeDataCollection.DeclareExchange(ExchangeName(typeToProcess));
            var baseType = typeToProcess.BaseType;

            while (baseType != null)
            {
                exchangeDataCollection.DeclareExchange(ExchangeName(baseType));
                exchangeDataCollection.BindExchange(ExchangeName(typeToProcess), ExchangeName(baseType));
                typeToProcess = baseType;
                baseType      = typeToProcess.BaseType;
            }

            foreach (var exchangeName in type.GetInterfaces().Select(ExchangeName))
            {
                exchangeDataCollection.DeclareExchange(exchangeName);
                exchangeDataCollection.BindExchange(ExchangeName(type), exchangeName);
            }
        }
Esempio n. 2
0
        public ExchangeCollection(ExchangeDataCollection dataCollection)
        {
            var toProcess         = new List <ExchangeData>(dataCollection.Exchanges);
            var workingCollection = new List <Exchange>();

            while (toProcess.Any())
            {
                BuildExchange(workingCollection, toProcess, dataCollection.Exchanges);
            }

            exchanges = workingCollection.ToArray();
        }
        async Task <Tuple <ExchangeDataCollection, int> > GetExchanges()
        {
            int expectedVersion;
            ExchangeDataCollection exchangesData;
            var readResult = await connection.ReadStreamEventsBackwardAsync(StreamName, -1, 1, true).ConfigureAwait(false);

            if (readResult.Status == SliceReadStatus.Success)
            {
                var @event = readResult.Events[0].Event;
                exchangesData   = @event.Data.ParseJson <ExchangeDataCollection>();
                expectedVersion = @event.EventNumber;
            }
            else
            {
                exchangesData   = new ExchangeDataCollection();
                expectedVersion = ExpectedVersion.NoStream;
            }
            return(Tuple.Create(exchangesData, expectedVersion));
        }
 void OnNewVersion(ExchangeDataCollection newData)
 {
     cachedExchangeCollection = new ExchangeCollection(newData);
 }