Esempio n. 1
0
 internal void OnStatistics(Portfolio portfolio, PortfolioStatisticsItem item)
 {
     foreach (var i in Items.Where(i => i != item))
     {
         i.OnStatistics(portfolio, item);
     }
 }
Esempio n. 2
0
 internal void Unsubscribe(PortfolioStatisticsItem item, int type)
 {
     if (this.subscriptions[type] != null && this.subscriptions[type].Contains(item.Type))
     {
         this.subscriptions[type].Remove(item.Type);
     }
     else
     {
         Console.WriteLine($"PortfolioStatistics::Unsubscribe Item {item.Type} is not subscribed for item {type}");
     }
 }
Esempio n. 3
0
        internal void OnStatistics(PortfolioStatisticsItem item)
        {
            var subscription = this.subscriptions[item.Type];

            if (subscription != null)
            {
                foreach (var type in subscription)
                {
                    Items.GetByType(type).OnStatistics(item);
                }
            }
        }
Esempio n. 4
0
 public void Add(PortfolioStatisticsItem item)
 {
     if (item.statistics == null)
     {
         item.statistics = this;
         item.portfolio  = this.portfolio;
         Items.Add(item);
         item.OnInit();
     }
     else
     {
         Console.WriteLine($"PortfolioStatistics::Add Error. Item already belongs to other statistics {item}");
     }
 }
Esempio n. 5
0
        internal void Subscribe(PortfolioStatisticsItem item, int type)
        {
            if (Items.GetByType(type) == null)
            {
                Add(this.portfolio.framework.StatisticsManager.Clone(type));
            }
            var subscription = this.subscriptions[type] = this.subscriptions[type] ?? new List <int>();

            if (subscription.Contains(item.Type))
            {
                Console.WriteLine($"PortfolioStatistics::Subscribe Item {item.Type} is already subscribed for item {type}");
            }
            else
            {
                subscription.Add(item.Type);
            }
        }
Esempio n. 6
0
 protected internal virtual void OnStatistics(Portfolio portfolio, PortfolioStatisticsItem statistics)
 {
     // noop
 }
 public void Add(PortfolioStatisticsItem item) => Statistics.Add(item);