コード例 #1
0
 public async Task SetSendStrategy(string id, ISendStrategy sendStrategy)
 {
     Console.WriteLine("Link: " + Utils.GetReadableName(self) + " " + sendStrategy);
     foreach (var receiver in sendStrategy.GetReceivers())
     {
         await receiver.AddInputInformation(self);
     }
     sendStrategies[id] = sendStrategy;
 }
コード例 #2
0
        public async Task LinkWorkerGrains()
        {
            Dictionary <string, int> inputInfo = new Dictionary <string, int>();

            foreach (IPrincipalGrain prevPrincipal in prevPrincipalGrains)
            {
                List <IWorkerGrain> prevOutputGrains = await prevPrincipal.GetOutputGrains();

                inputInfo[prevPrincipal.GetPrimaryKey().ToString()] = prevOutputGrains.Count;
            }
            if (inputInfo.Count > 0)
            {
                foreach (IWorkerGrain grain in inputGrains)
                {
                    await grain.SetInputInformation(inputInfo);
                }
            }

            if (nextPrincipalGrains.Count != 0)
            {
                foreach (IPrincipalGrain nextPrincipal in nextPrincipalGrains)
                {
                    ISendStrategy strategy = await nextPrincipal.GetInputSendStrategy();

                    for (int i = 0; i < outputGrains.Count; ++i)
                    {
                        await outputGrains[i].SetSendStrategy(operatorID, strategy);
                    }
                }
            }
            else
            {
                //last operator, build stream
                var           streamProvider = GetStreamProvider("SMSProvider");
                var           stream         = streamProvider.GetStream <Immutable <PayloadMessage> >(workflowID, "OutputStream");
                ISendStrategy strategy       = new SendToStream(stream);
                foreach (IWorkerGrain grain in outputGrains)
                {
                    await grain.SetSendStrategy(workflowID, strategy);
                }
            }
        }
コード例 #3
0
 public CompoundStrategy(ISendStrategy sendStrategy, IRecieveStrategy recieveStrategy)
 {
     SendStrategy    = sendStrategy;
     RecieveStrategy = recieveStrategy;
 }
コード例 #4
0
 public Task SetSendStrategy(Guid operatorGuid, ISendStrategy sendStrategy)
 {
     sendStrategies[operatorGuid] = sendStrategy;
     return(Task.CompletedTask);
 }