Beispiel #1
0
        public void Execute(MessageContext messagecontext, Action <MessageContext, MiddlewareContext> next, MiddlewareContext middlewarecontext)
        {
            var data = Activator.CreateInstance(messagecontext.Saga.DataType);

            var storage = _factory.Create <ISagaStorage>(Configuration.SagaStorageType);

            var serializer = _factory.Create <IMessageSerializer>(Configuration.MessageSerializerType);

            messagecontext.SagaContext.Status = DefaultStatus;

            var sagaentity = CreateSagaEntity(messagecontext);

            sagaentity.Data = serializer.Serialize(data);

            messagecontext.SagaContext.Id = storage.CreateSaga(messagecontext, sagaentity);

            messagecontext.AddTrack(messagecontext.Identity, messagecontext.Origin, messagecontext.Route, messagecontext.Saga, messagecontext.SagaContext);

            _router.Route(messagecontext, data);

            sagaentity.Updated = messagecontext.DateTimeUtc;

            SaveSaga(messagecontext, storage, sagaentity, serializer, data);

            SaveMessage(messagecontext, storage, sagaentity);
        }
        public void Run(DateTime datetime)
        {
            if (_configuration.LoggerTypes.ContainsKey(typeof(PointToPointChannelInfo)))
            {
                var loggertypes = _configuration.LoggerTypes[typeof(PointToPointChannelInfo)];

                var loggers = loggertypes.Select(x => _factory.Create <ILogger <PointToPointChannelInfo> >(x)).ToArray();

                var channelmanager = _factory.Create <IChannelManager>(_configuration.ChannelManagerType);

                foreach (var source in _sources)
                {
                    var queues = source.GetPointToPointChannels();

                    foreach (var queue in queues)
                    {
                        var info = GetPointToPointChannel(queue, channelmanager);

                        if (info != null)
                        {
                            Array.ForEach(loggers, x => x.Log(info, datetime));
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public object Reply(Channel channel, MessageContext context, string channelpath)
        {
            Send(channel, context, channelpath);

            MessageContext outputcontext = null;

            var adapter = Factory.Create <IMessageAdapter>(Configuration.MessageAdapterType);

            try
            {
                outputcontext = string.IsNullOrWhiteSpace(channel.ToReplySubscription) ? ReceiveOnQueue(channel, context, adapter) : ReceiveOnTopic(channel, context, adapter);
            }
            catch (Exception ex)
            {
                Logger.Log($"Message {outputcontext?.Identity.Id} failed to arrived to {Name} channel {channelpath} {ex}");

                throw;
            }
            finally
            {
                Logger.Log($"Message {outputcontext?.Identity.Id} arrived to {Name} channel {channelpath}");
            }

            if (outputcontext != null)
            {
                return(adapter.Deserialize(outputcontext.Content, outputcontext.ContentType));
            }

            return(null);
        }
        public void Run()
        {
            var channelmanager = _factory.Create <IChannelManager>(_configuration.ChannelManagerType);

            foreach (var source in _sources)
            {
                var queues = source.GetPointToPointChannels();

                foreach (var queue in queues)
                {
                    CreatePointToPointChannel(queue, channelmanager);
                }
            }

            foreach (var source in _sources)
            {
                var topics = source.GetPublishSubscribeChannels();

                foreach (var topic in topics)
                {
                    CreatePublishSubscriberChannel(topic, channelmanager);
                }
            }

            foreach (var source in _sources)
            {
                var subscriptions = source.GetSubscriptionsToPublishSubscribeChannel();

                foreach (var subscription in subscriptions)
                {
                    CreateSubscriptionToPublishSubscribeChannel(subscription, channelmanager);
                }
            }
        }
Beispiel #5
0
        public void BuildEntity(Entity entity, params object[] args)
        {
            string    dataFile  = "./Levels/" + args[0] + ".json";
            LevelData levelData = _dataManager.Load <LevelData>(dataFile);

            Nameable nameable = _componentFactory.Create <Nameable>();

            nameable.Name = levelData.Name;

            Map map = _componentFactory.Create <Map>();

            map.Width       = levelData.Width;
            map.Height      = levelData.Height;
            map.Spritesheet = _contentManager.Load <Texture2D>("./Graphics/Tilesets/" + levelData.Spritesheet);
            map.Tiles       = levelData.Tiles;
            map.BGM         = _contentManager.Load <Song>("./Audio/BGM/" + levelData.BGMFile);

            Script script = _componentFactory.Create <Script>();

            script.FilePath = "Levels/" + levelData.Script;

            Heartbeat hb = _componentFactory.Create <Heartbeat>();

            hb.Interval = 1.0f;

            MediaPlayer.IsRepeating = true;
            MediaPlayer.Play(map.BGM);

            entity.AddComponent(nameable);
            entity.AddComponent(map);
            entity.AddComponent(script);
            entity.AddComponent(hb);
        }
        public override MessageEntity[] GetMessagesBySaga(SagaEntity sagaentity, string messagestoragename = "")
        {
            var serializer = _factory.Create <IMessageSerializer>(_configuration.MessageSerializerType);

            var table = GetCloudTable(_connectionstring, $"{_messagestorgename}{_currenttablenamesufix}");

            if (!string.IsNullOrWhiteSpace(messagestoragename))
            {
                table = GetCloudTable(_connectionstring, $"{messagestoragename}");
            }

            var records = table.CreateQuery <MessageRecord>().Where(x => x.PartitionKey == sagaentity.Key);

            return(records.Select(x => new MessageEntity()
            {
                Content = x.Content,
                ContentType = x.ContentType,
                Id = x.Id,
                Version = x.Version,
                RetryCount = x.RetryCount,
                LastRetry = x.LastRetry,
                Origin = serializer.Deserialize <Origin>(x.Origin),
                Saga = serializer.Deserialize <SagaContext>(x.Saga),
                Headers = serializer.Deserialize <Dictionary <string, string> >(x.Headers),
                DateTimeUtc = x.DateTimeUtc,
                Data = x.Data,
                Name = x.Name
            }).ToArray());
        }
Beispiel #7
0
        public void Run(DateTime datetime)
        {
            if (_configuration.LoggerTypes.ContainsKey(typeof(SubscriptionToPublishSubscribeChannelInfo)))
            {
                var loggertypes = _configuration.LoggerTypes[typeof(SubscriptionToPublishSubscribeChannelInfo)];

                var loggers = loggertypes.Select(x => _factory.Create <ILogger <SubscriptionToPublishSubscribeChannelInfo> >(x)).ToArray();

                var channelmanager = _factory.Create <IChannelManager>(_configuration.ChannelManagerType);

                foreach (var source in _sources)
                {
                    var subscriptions = source.GetSubscriptionsToPublishSubscribeChannel();

                    foreach (var subscription in subscriptions)
                    {
                        var info = GetSubscriptionToPublishSubscribeChannel(subscription, channelmanager);

                        if (info != null)
                        {
                            Array.ForEach(loggers, x => x.Log(info, datetime));
                        }
                    }
                }
            }
        }
Beispiel #8
0
        public override MessageEntity[] GetMessagesBySaga(SagaEntity sagaentity, string messagestoragename = "")
        {
            var serializer = _factory.Create <IMessageSerializer>(_configuration.MessageSerializerType);

            var table = GetCloudTable(_connectionstring, $"{_messagestorgename}{_currenttablenamesufix}");

            if (!string.IsNullOrWhiteSpace(messagestoragename))
            {
                table = GetCloudTable(_connectionstring, $"{messagestoragename}");
            }

            var where = TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, sagaentity.Key);

            var query = new TableQuery <MessageRecord>().Where(where);

            var records = ExecuteQuery <MessageRecord>(table, query);

            return(records.Select(x => new MessageEntity()
            {
                Content = x.Content,
                ContentType = x.ContentType,
                Identity = string.IsNullOrWhiteSpace(x.Identity) ? null: serializer.Deserialize <Identity>(x.Identity),
                Version = x.Version,
                RetryCount = x.RetryCount,
                LastRetry = x.LastRetry,
                Origin = string.IsNullOrWhiteSpace(x.Origin) ? null : serializer.Deserialize <Origin>(x.Origin),
                Saga = string.IsNullOrWhiteSpace(x.Saga) ? null : serializer.Deserialize <SagaContext>(x.Saga),
                Headers = string.IsNullOrWhiteSpace(x.Headers) ? null : serializer.Deserialize <Dictionary <string, string> >(x.Headers),
                DateTimeUtc = x.DateTimeUtc,
                Data = x.Data,
                Name = x.Name,
                ContentId = x.ContentId
            }).ToArray());
        }
        public object Reply(MessageContext context)
        {
            var channelpath = _builder.BuildReplyFromContext(context);

            Send(context);

            MessageContext outputcontext = null;

            var adapter = Factory.Create <IMessageAdapter>(Configuration.MessageAdapterType);

            try
            {
                outputcontext = string.IsNullOrWhiteSpace(context.ToReplySubscription) ? ReceiveOnQueue(context, adapter) : ReceiveOnTopic(context, adapter);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Message {outputcontext?.Id} failed to arrived to {ChannelName} channel {channelpath} {ex}");

                throw;
            }
            finally
            {
                Console.WriteLine($"Message {outputcontext?.Id} arrived to {ChannelName} channel {channelpath}");
            }

            if (outputcontext != null)
            {
                return(adapter.Deserialize(outputcontext.ContentAsString, outputcontext.ContentType));
            }

            return(null);
        }
Beispiel #10
0
        public void BuildEntity(Entity entity, params object[] args)
        {
            string textureFile = args[0] as string;
            int?   x           = args[1] as int?;
            int?   y           = args[2] as int?;

            string filePath = ".\\Graphics\\Backgrounds\\" + textureFile;

            StaticGraphic staticGraphic = _componentFactory.Create <StaticGraphic>();

            staticGraphic.Scrolls = true;
            staticGraphic.Texture = _content.Load <Texture2D>(filePath);
            entity.AddComponent(staticGraphic);

            Position position = _componentFactory.Create <Position>();

            position.X = x ?? 0;
            position.Y = y ?? 0;
            entity.AddComponent(position);

            Entity existingBackground = EntitySystem.BlackBoard.GetEntry <Entity>("Background");

            existingBackground?.Delete();

            EntitySystem.BlackBoard.SetEntry("Background", entity);
        }
Beispiel #11
0
        public void TestFactoryReturnsCorrectInstanceType()
        {
            var component = _componentFactory.Create <ISimpleComponent>();

            component.ShouldNotBeNull();
            component.ShouldBeAssignableTo <ISimpleComponent>();
            component.ShouldBeOfType <SimpleComponent>();
        }
Beispiel #12
0
        public void Route(object message, Route route)
        {
            var adapter = _factory.Create <IMessageAdapter>(_configuration.MessageAdapterType);

            var interceptor = _factory.Create <IRouterInterceptor>(_configuration.RouterInterceptorType);

            var context = adapter.Read(message, route.ContentType);

            interceptor.OnEntry(context);

            var when = true;

            if (route.When != null)
            {
                when = route.When(context);
            }

            if (when)
            {
                try
                {
                    var middlewares = new List <Type> {
                        typeof(MessageExceptionHandler)
                    };

                    middlewares.AddRange(_configuration.InboundMiddlewareTypes);

                    middlewares.AddRange(route.MiddlewareTypes);

                    middlewares.Add(typeof(MessageHandler));

                    var parameter = new MiddlewareParameter()
                    {
                        Route = route
                    };

                    context.Route = route;

                    var pipeline = new Pipeline(_factory, middlewares.ToArray(), context, parameter);

                    pipeline.Execute();

                    interceptor.OnSuccess(context);
                }
                catch (Exception ex)
                {
                    interceptor.OnException(context, ex);

                    throw;
                }
                finally
                {
                    interceptor.OnExit(context);
                }
            }
        }
Beispiel #13
0
        public void Execute(MessageContext context, Action next, MiddlewareParameter parameter)
        {
            var storage = _factory.Create <IStorage>(_configuration.StorageType);

            var serializer = _factory.Create <IMessageSerializer>(_configuration.MessageSerializerType);

            var sagaentity = storage.GetSaga(context.SagaContext.Id);

            context.SagaContext.Status = DefaultStatus;

            if (sagaentity != null)
            {
                var data = serializer.Deserialize(sagaentity.Data, parameter.Saga.DataType);

                context.AddTrack(context.Id, context.Origin.Key, context.Origin.From, parameter.Route.Name, context.SagaContext.Id, parameter.Saga.Name);

                if (data != null)
                {
                    _router.Route(context, parameter.Route, data, parameter.Saga.DataType);

                    sagaentity.Data = serializer.Serialize(data);

                    sagaentity.Ended = context.DateTimeUtc;

                    sagaentity.Status = context.SagaContext.Status;

                    sagaentity.Duration = (sagaentity.Ended.Value - sagaentity.Created).TotalMilliseconds;

                    storage.UpdateSaga(context, context.SagaContext.Id, sagaentity);

                    var message = CreateMessageEntity(context, parameter, sagaentity);

                    try
                    {
                        storage.CreateMessage(context, context.SagaContext.Id, sagaentity, message);
                    }
                    catch (Exception)
                    {
                        if (!_configuration.Storage.IgnoreExceptionOnSaveMessage)
                        {
                            throw;
                        }
                    }
                }
                else
                {
                    throw new ApplicationException($"Empty/Invalid data {parameter.Saga.DataType.FullName} for {parameter.Route.ContentType.FullName}, saga {parameter.Saga.Name}");
                }
            }
            else
            {
                throw new ApplicationException($"No data {parameter.Saga.DataType.FullName} for {parameter.Route.ContentType.FullName}, saga {parameter.Saga.Name}");
            }
        }
        public void Execute(MessageContext context, Action next, MiddlewareParameter parameter)
        {
            var data = Activator.CreateInstance(parameter.Saga.DataType);

            var storage = _factory.Create <IStorage>(_configuration.StorageType);

            var serializer = _factory.Create <IMessageSerializer>(_configuration.MessageSerializerType);

            context.SagaContext.Status = DefaultStatus;

            var sagaentity = CreateSagaEntity(context, parameter);

            sagaentity.Data = serializer.Serialize(data);

            var id = storage.CreateSaga(context, sagaentity);

            context.SagaContext.Id = id;

            context.AddTrack(context.Id, context.Origin.Key, context.Origin.From, parameter.Route.Name, context.SagaContext.Id, parameter.Saga.Name);

            _router.Route(context, parameter.Route, data, parameter.Saga.DataType);

            sagaentity = storage.GetSaga(id);

            if (sagaentity != null)
            {
                sagaentity.Data = serializer.Serialize(data);

                sagaentity.Updated = context.DateTimeUtc;

                sagaentity.Status = context.SagaContext.Status;

                storage.UpdateSaga(context, id, sagaentity);

                var messageentity = CreateMessageEntity(context, parameter, sagaentity);

                try
                {
                    storage.CreateMessage(context, id, sagaentity, messageentity);
                }
                catch (Exception)
                {
                    if (!_configuration.Storage.IgnoreExceptionOnSaveMessage)
                    {
                        throw;
                    }
                }
            }
            else
            {
                throw new ApplicationException($"No data {parameter.Saga.DataType.FullName} for {parameter.Route.ContentType.FullName}, saga {parameter.Saga.Name}");
            }
        }
Beispiel #15
0
        /// <inheritdoc />
        public void BuildEntity(Entity entity)
        {
            entity.AddComponent(_componentFactory.Create <Nameable>());
            entity.AddComponent(_componentFactory.Create <Tag>());
            entity.AddComponent(_componentFactory.Create <Resref>());
            entity.AddComponent(_componentFactory.Create <Description>());

            ScriptGroup scriptGroup = _componentFactory.Create <ScriptGroup>();

            scriptGroup.Add(ScriptEvent.OnAbilityActivated, string.Empty);

            entity.AddComponent(scriptGroup);
        }
        public object Deserialize(string content, Type type)
        {
            var serializer = Factory.Create <IMessageSerializer>(Configuration.MessageSerializerType);

            try
            {
                return(serializer.Deserialize(content, type));
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #17
0
        public object?ReadValue(JsonObject source)
        {
            if (!source.TryGet(nameof(IEntity.Components), out var componentsData))
            {
                return(null);
            }

            var components = new LocalList <IComponent>();

            foreach (var(name, data) in (JsonObject)componentsData)
            {
                var componentType = _descriptions.GetComponentType(name);

                var component = _componentFactory.Create(componentType);

                var componentConverter = (IObjectConverter)_converters.Get(componentType);
                var filledComponent    = componentConverter.FillObject((JsonObject)data, component);

                if (filledComponent != null)
                {
                    components.Add((IComponent)filledComponent);
                }
            }

            return(components.ToArray());
        }
Beispiel #18
0
        public void Execute(MessageContext context, Action next, MiddlewareParameter parameter)
        {
            var channel = _factory.Create <IRequestReplyChannel>(_configuration.RequestReplyChannelType);

            var result = channel.Reply(context);

            parameter.Result = result;
        }
Beispiel #19
0
        public void BuildEntity(Entity entity, params object[] args)
        {
            string   itemResourceFile = args[0] as string;
            string   dataFile         = "\\Items\\" + itemResourceFile + ".json";
            ItemData data             = _dataManager.Load <ItemData>(dataFile);

            Sprite sprite = _componentFactory.Create <Sprite>();

            sprite.Texture = _contentManager.Load <Texture2D>(".\\Graphics\\" + _fileSystem.Path.ChangeExtension(data.TextureFile, null));
            foreach (Animation animation in data.Animations)
            {
                sprite.Animations.Add(animation.Name, animation);
                if (animation.IsDefaultAnimation)
                {
                    sprite.SetCurrentAnimation(animation.Name);
                }
            }

            entity.AddComponent(sprite);
            Position position = _componentFactory.Create <Position>();

            position.X = (int?)args[1] ?? 0;
            position.Y = (int?)args[2] ?? 0;
            entity.AddComponent(position);
            entity.AddComponent(_componentFactory.Create <Renderable>());
            entity.AddComponent(_componentFactory.Create <Velocity>());
            entity.AddComponent(_componentFactory.Create <LocalData>());

            Nameable nameable = _componentFactory.Create <Nameable>();

            nameable.Name = data.Name;
            entity.AddComponent(nameable);

            Script script = _componentFactory.Create <Script>();

            script.FilePath = data.Script;
            entity.AddComponent(script);

            CollisionBox box = _componentFactory.Create <CollisionBox>();

            box.Width   = data.CollisionWidth;
            box.Height  = data.CollisionHeight;
            box.OffsetX = data.CollisionOffsetX;
            box.OffsetY = data.CollisionOffsetY;
            entity.AddComponent(box);

            Gravity gravity = _componentFactory.Create <Gravity>();

            gravity.Speed = 4.0f;
            entity.AddComponent(gravity);
        }
        public IComponent Export()
        {
            using (_logger.Scope("Exporting active entities to component."))
            {
                var rootComponent = _factory.Create();

                // Apply the active entities to the component tree.
                var activeEvents = _table
                                   .GetActiveEntities <EventEntity>()
                                   .ToList()
                                   .Where(e =>
                                          _table
                                          .GetChildEntities <MessageEntity, EventEntity>(e)
                                          .ToList()
                                          .Any())
                                   .ToList();

                _logger.LogInformation("Found {EventCount} active events with messages.", activeEvents.Count);

                var activeIncidentGroups = activeEvents
                                           .SelectMany(e =>
                                                       _table
                                                       .GetChildEntities <IncidentGroupEntity, EventEntity>(e)
                                                       .Where(i => i.IsActive)
                                                       .ToList())
                                           .ToList();

                _logger.LogInformation("Found {GroupCount} active incident groups linked to active events with messages.", activeIncidentGroups.Count);

                var activeEntities = activeIncidentGroups
                                     .Concat <IComponentAffectingEntity>(activeEvents)
                                     // Only apply entities with a non-Up status.
                                     .Where(e => e.AffectedComponentStatus != (int)ComponentStatus.Up)
                                     // If multiple events are affecting a single region, the event with the highest severity should affect the component.
                                     .GroupBy(e => e.AffectedComponentPath)
                                     .Select(g => g.OrderByDescending(e => e.AffectedComponentStatus).First())
                                     .ToList();

                _logger.LogInformation("Active entities affect {PathCount} distinct subcomponents.", activeEntities.Count);
                foreach (var activeEntity in activeEntities)
                {
                    using (_logger.Scope("Applying active entity affecting {AffectedComponentPath} of severity {AffectedComponentStatus} at {StartTime} to root component",
                                         activeEntity.AffectedComponentPath, (ComponentStatus)activeEntity.AffectedComponentStatus, activeEntity.StartTime))
                    {
                        var currentComponent = rootComponent.GetByPath(activeEntity.AffectedComponentPath);

                        if (currentComponent == null)
                        {
                            throw new InvalidOperationException($"Couldn't find component with path {activeEntity.AffectedComponentPath} corresponding to active entities.");
                        }

                        currentComponent.Status = (ComponentStatus)activeEntity.AffectedComponentStatus;
                    }
                }

                return(rootComponent);
            }
        }
Beispiel #21
0
        public async Task IterateAsync(IEnumerable <MessageChangeEvent> changes, EventEntity eventEntity)
        {
            var rootComponent = _factory.Create();
            ExistingStartMessageContext existingStartMessageContext = null;

            foreach (var change in changes.OrderBy(c => c.Timestamp))
            {
                existingStartMessageContext = await _processor.ProcessAsync(change, eventEntity, rootComponent, existingStartMessageContext);
            }
        }
Beispiel #22
0
        public void Execute <TContent, THandler>(MessageContext context, Route <TContent, THandler> route) where THandler : class
        {
            if (route.RouteMethods != null)
            {
                var adapter = _factory.Create <IMessageAdapter>(_configuration.MessageAdapterType);

                var handler = _factory.Create <THandler>(route.ConsumerType);

                var content = adapter.Deserialize <TContent>(context.Content);

                foreach (var method in route.RouteMethods)
                {
                    if (_selector.Select(context, content, method, handler))
                    {
                        _executor.Execute(context, content, method, handler);
                    }
                }
            }
        }
Beispiel #23
0
        private void SendRetry(Route route, MessageContext context, IRetryPolicy policy)
        {
            var options = new Options()
            {
                EndPointName = route.OnRetryEndPoint,
                Headers      = context.Headers,
                Identity     = context.Identity,
                Version      = context.Version,
                ScheduledEnqueueDateTimeUtc = DateTime.UtcNow.Add(policy.NextRetryInterval(context.RetryCount + 1)),
                RetryCount  = context.RetryCount + 1,
                SagaContext = context.SagaContext,
            };

            var adapter = _factory.Create <IMessageAdapter>(_configuration.MessageAdapterType);

            var content = adapter.Deserialize(context.Content, context.ContentType);

            _bus.Send(content, context.Origin, options);
        }
Beispiel #24
0
        public object Execute(MessageContext context, Func <MessageContext, MiddlewareContext, object> next, MiddlewareContext middlewarecontext)
        {
            if (middlewarecontext.Channel.IsValidEndpoint())
            {
                var channel = _factory.Create <IPublishSubscribeChannel>(_configuration.PublishSubscribeChannelType);

                channel.Send(middlewarecontext.Channel, context, middlewarecontext.Channel.GetPath(context.EndPoint.Name));
            }

            return(null);
        }
Beispiel #25
0
        /// <inheritdoc />
        public void BuildEntity(Entity entity, Texture2D texture)
        {
            var renderable = _factory.Create <Renderable>();
            var position   = _factory.Create <Position>();
            var paintable  = _factory.Create <Paintable>();

            renderable.Texture = texture;
            renderable.Source  = new Rectangle(
                0,
                0,
                _engineService.TileWidth,
                _engineService.TileHeight);
            //renderable.Origin = new Vector2(
            //    _engineService.TileWidth / 2.0f,
            //    _engineService.TileHeight / 2.0f);

            entity.AddComponent(renderable);
            entity.AddComponent(position);
            entity.AddComponent(paintable);
        }
Beispiel #26
0
        public void Run()
        {
            var errors = new StringBuilder();

            var channelmanager = _factory.Create <IChannelManager>(_configuration.ChannelManagerType);

            foreach (var source in _sources)
            {
                var queues = source.GetPointToPointChannels();

                foreach (var queue in queues)
                {
                    CreatePointToPointChannel(queue, channelmanager, errors);
                }
            }

            foreach (var source in _sources)
            {
                var topics = source.GetPublishSubscribeChannels();

                foreach (var topic in topics)
                {
                    CreatePublishSubscriberChannel(topic, channelmanager, errors);
                }
            }

            foreach (var source in _sources)
            {
                var subscriptions = source.GetSubscriptionsToPublishSubscribeChannel();

                foreach (var subscription in subscriptions)
                {
                    CreateSubscriptionToPublishSubscribeChannel(subscription, channelmanager, errors);
                }
            }

            if (!string.IsNullOrWhiteSpace(errors.ToString()))
            {
                throw new ApplicationException(errors.ToString());
            }
        }
Beispiel #27
0
 private Action GetNext()
 {
     return(() =>
     {
         if (_current < _middlewares.Length)
         {
             var middleware = _factory.Create <IMiddleware>(_middlewares[_current]);
             _current++;
             middleware.Execute(_context, GetNext(), _parameter);
         }
     });
 }
Beispiel #28
0
 private Action <MessageContext, MiddlewareContext> GetNext()
 {
     return((c, p) =>
     {
         if (p.Index < p.MiddlewareTypes.Length)
         {
             var middleware = _factory.Create <IMiddleware>(p.MiddlewareTypes[p.Index]);
             p.Index++;
             middleware.Execute(c, GetNext(), p);
         }
     });
 }
Beispiel #29
0
        public void BuildEntity(Entity entity, params object[] args)
        {
            int    width       = (int)args[0];
            int    height      = (int)args[1];
            string name        = (string)args[2];
            string texturePath = (string)args[3];

            TileData[,] tiles = (TileData[, ])args[4];

            Map map = _componentFactory.Create <Map>();

            map.Width       = width;
            map.Height      = height;
            map.Spritesheet = _content.Load <Texture2D>(".\\Graphics\\Tilesets\\" + texturePath);
            map.Tiles       = tiles;
            entity.AddComponent(map);

            Nameable nameable = _componentFactory.Create <Nameable>();

            nameable.Name = name;
            entity.AddComponent(nameable);
        }
Beispiel #30
0
        public object Execute(MessageContext context, Func <MessageContext, MiddlewareContext, object> next, MiddlewareContext middlewarecontext)
        {
            if (middlewarecontext.Channel.IsValidReplyEndpoint() && !string.IsNullOrWhiteSpace(context.Identity.ReplyToRequestId))
            {
                var channel = _factory.Create <IRequestReplyChannel>(_configuration.RequestReplyChannelType);

                var result = channel.Reply(middlewarecontext.Channel, context, middlewarecontext.Channel.GetPath(context.EndPoint.Name));

                return(result);
            }

            return(null);
        }