コード例 #1
0
        public Dictionary <string, List <BarScaleInterval> > SymbolsScaleIntervalsBarConsumerRegistered(IStreamingConsumer consumer)
        {
            Dictionary <string, List <BarScaleInterval> > ret = null;

            foreach (string symbol in this.DistributionChannels.Keys)
            {
                Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> consumersByScaleInterval = DistributionChannels[symbol];
                foreach (BarScaleInterval scaleInterval in consumersByScaleInterval.Keys)
                {
                    SymbolScaleDistributionChannel consumers = consumersByScaleInterval[scaleInterval];
                    if (consumers.ConsumersBarContains(consumer))
                    {
                        if (ret == null)
                        {
                            ret = new Dictionary <string, List <BarScaleInterval> >();
                        }
                        if (ret.ContainsKey(symbol) == false)
                        {
                            ret.Add(symbol, new List <BarScaleInterval>());
                        }
                        ret[symbol].Add(scaleInterval);
                    }
                }
            }
            return(ret);
        }
コード例 #2
0
 public void ConsumerBarUnRegister(string symbol, BarScaleInterval scaleInterval, IStreamingConsumer consumer)
 {
     if (consumer is StaticProvider)
     {
         int a = 1;
     }
     lock (lockConsumersBySymbol) {
         if (this.DistributionChannels.ContainsKey(symbol) == false)
         {
             Assembler.PopupException("Can't unregister BarConsumer [" + consumer + "]: symbol[" + symbol + "] is not registered for any consumers; returning");
             return;
         }
         Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> distributorsByScaleInterval = this.DistributionChannels[symbol];
         if (distributorsByScaleInterval.ContainsKey(scaleInterval) == false)
         {
             string symbolDistributorsAsString = "";
             foreach (SymbolScaleDistributionChannel d in distributorsByScaleInterval.Values)
             {
                 symbolDistributorsAsString += d + ",";
             }
             symbolDistributorsAsString.TrimEnd(',');
             Assembler.PopupException("Can't unregister BarConsumer [" + consumer + "]: scaleInterval[" + scaleInterval + "] not found among distributors [" + symbolDistributorsAsString + "]; returning");
             return;
         }
         SymbolScaleDistributionChannel distributor = distributorsByScaleInterval[scaleInterval];
         if (distributor.ConsumersBarContains(consumer) == false)
         {
             Assembler.PopupException("Can't unregister BarConsumer [" + consumer + "]: consumer not found in [" + distributor.ConsumersBarAsString + "]; returning");
             return;
         }
         distributor.ConsumersBarRemove(consumer);
         if (distributor.ConsumersBarCount == 0 && distributor.ConsumersQuoteCount == 0)
         {
             //Assembler.PopupException("BarConsumer [" + consumer + "] was the last one using [" + symbol + "][" + scaleInterval + "]; removing QuoteBarDistributor[" + distributor + "]");
             distributorsByScaleInterval.Remove(scaleInterval);
             if (distributorsByScaleInterval.Count == 0)
             {
                 //Assembler.PopupException("BarConsumer [" + scaleInterval + "] was the last one listening for [" + symbol + "]");
                 //Assembler.PopupException("...removing[" + symbol + "] from this.DistributionChannels[" + this.DistributionChannels + "]");
                 this.DistributionChannels.Remove(symbol);
                 //Assembler.PopupException("...UpstreamUnSubscribing [" + symbol + "]");
                 this.StreamingProvider.UpstreamUnSubscribe(symbol);
             }
         }
     }
 }
コード例 #3
0
 public void ConsumerBarRegister(string symbol, BarScaleInterval scaleInterval, IStreamingConsumer consumer)
 {
     if (consumer is StaticProvider)
     {
         int a = 1;
     }
     lock (lockConsumersBySymbol) {
         if (this.DistributionChannels.ContainsKey(symbol) == false)
         {
             SymbolScaleDistributionChannel newChannel = new SymbolScaleDistributionChannel(symbol, scaleInterval);
             newChannel.ConsumersBarAdd(consumer);
             Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> newScaleChannels = new Dictionary <BarScaleInterval, SymbolScaleDistributionChannel>();
             newScaleChannels.Add(scaleInterval, newChannel);
             this.DistributionChannels.Add(symbol, newScaleChannels);
             if (this.StreamingProvider.UpstreamIsSubscribed(symbol) == false)
             {
                 this.StreamingProvider.UpstreamSubscribe(symbol);
             }
             return;
         }
         Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> channels = this.DistributionChannels[symbol];
         if (channels.ContainsKey(scaleInterval) == false)
         {
             SymbolScaleDistributionChannel newChannel = new SymbolScaleDistributionChannel(symbol, scaleInterval);
             newChannel.ConsumersBarAdd(consumer);
             channels.Add(scaleInterval, newChannel);
             return;
         }
         SymbolScaleDistributionChannel channel = channels[scaleInterval];
         if (channel.ConsumersBarContains(consumer) == false)
         {
             channel.ConsumersBarAdd(consumer);
             return;
         }
         Assembler.PopupException("BarConsumer [" + consumer + "] already registered for [" + channel + "]; returning");
     }
 }