Пример #1
0
        public static void Connect <TComponent, TMessage>(this ActorSystemSetup actorSystemSetup,
                                                          ActorSetup outputActorSetup, ActorSetup inputActorSetup)
        {
            var componentConfig = actorSystemSetup.GetComponentConfig <TComponent>();
            var messageTypeName = typeof(TMessage).ToString();

            var outputActorConfig = actorSystemSetup.GetActorConfig(outputActorSetup);
            var inputActorConfig  = actorSystemSetup.GetActorConfig(inputActorSetup);

            var outputPortConfig = outputActorConfig.OutputConfigs.First(x =>
                                                                         x.ComponentConfigId == componentConfig.Id && x.MessageTypeNormalizedFullName == messageTypeName);
            var inputPortConfig = inputActorConfig.InputConfigs.First(x =>
                                                                      x.ComponentConfigId == componentConfig.Id && x.MessageTypeNormalizedFullName == messageTypeName);

            var outputPort = outputActorSetup.Outputs.First(x => x.ConfigId == outputPortConfig.Id);
            var inputPort  = inputActorSetup.Inputs.First(x => x.ConfigId == inputPortConfig.Id);

            var link = new ActorLink(outputPort.Id, inputPort.Id, false);

            outputPort.Links.Add(link);
            inputPort.Links.Add(link);
        }
Пример #2
0
        public static ActorSetup CreateActorSetup <T>(this ActorSystemSetup actorSystemSetup)
        {
            var actorConfig = actorSystemSetup.GetActorConfig <T>();
            var actorSetup  = actorConfig.CreateActorSetup();

            actorSystemSetup.ActorSetups.Add(actorSetup);
            foreach (var inputConfig in actorConfig.InputConfigs)
            {
                var isValid = MultiplicityValidator.IsValid(actorSystemSetup.ComponentConfigs.First(x => x.Id == inputConfig.ComponentConfigId).InputMultiplicity, 0);
                actorSetup.Inputs.Add(new ActorPort(Guid.NewGuid().ToString(), inputConfig.Id, new List <ActorLink>(), isValid, false));
            }
            foreach (var outputConfig in actorConfig.OutputConfigs)
            {
                var isValid = MultiplicityValidator.IsValid(actorSystemSetup.ComponentConfigs.First(x => x.Id == outputConfig.ComponentConfigId).OutputMultiplicity, 0);
                actorSetup.Outputs.Add(new ActorPort(Guid.NewGuid().ToString(), outputConfig.Id, new List <ActorLink>(), isValid, false));
            }
            return(actorSetup);
        }
Пример #3
0
        public static ActorSetup GetActorSetup <T>(this ActorSystemSetup actorSystemSetup)
        {
            var actorConfig = actorSystemSetup.GetActorConfig <T>();

            return(actorSystemSetup.ActorSetups.First(x => x.ConfigId == actorConfig.Id));
        }