Example #1
0
        public IEnumerable <IGlobeResident> Traverse(BgaRootModel model)
        {
            model.InitializeWhenDeSerializationIsDone();
            var result = new List <IGlobeResident>();

            this.TraverseGlobe(model.Globe, result);

            var cash     = model.Cash;
            var cashLine = new CashLineModel(
                cash.Base,
                cash.Scaled,
                cash.TrueExposure,
                cash.TrueActive
                );

            cashLine.Parent = model.Globe;
            result.Add(cashLine);

            var globe = model.Globe;

            var totalLine = new TotalLineModel(
                model.BaseGrandTotal,
                globe.Benchmark,
                globe.Overlay,
                globe.PortfolioAdjustment,
                model.PortfolioScaledGrandTotal,
                model.TrueExposureGrandTotal,
                model.TrueActiveGrandTotal
                );

            totalLine.Parent = model.Globe;
            result.Add(totalLine);

            return(result);
        }
Example #2
0
        protected void TakeData(BgaRootModel data)
        {
            this.defaultExpandCollapseStateSetter.SetDefaultCollapseExpandState(data.Globe);
            var residents = this.traverser.Traverse(data);

            // register for listening to any change to base and portfolio adjustment, if change happens we need to initiate recalculation
            this.RegisterResidentsForValueChangeWatch(residents);
            this.RegisterOveralyFactorsForValueChangeWatch(data.Factors);

            // we need an observable collection to make filtering (collapsing/expanding) work, because it is triggered by the CollectionChanged event
            this.Residents = new ObservableCollection <IGlobeResident>(residents);
            this.Factors   = new ObservableCollection <BgaFactorItemModel>(data.Factors.Items);
            this.RootModel = data;

            var targetingTypeId = this.LastValidInput.TargetingTypeId;
            var portfolioId     = this.LastValidInput.BroadGlobalActivePortfolioId;

            var registeredExpressions = new List <EditableExpressionModel>();

            foreach (var factor in factors)
            {
                EditableExpressionModel factorExpression = factor.OverlayFactor;
                var securityId = factor.BottomUpPortfolio.Fund.Id;
                var requestOverlayFactorCommentsCommand = new DelegateCommand(delegate
                {
                    this.RequestOverlayFactorComments(portfolioId, securityId);
                });
                factorExpression.RegisterForBeingWatched(this, requestOverlayFactorCommentsCommand);
                registeredExpressions.Add(factorExpression);
            }

            foreach (var resident in residents)
            {
                var basketId = -1;

                EditableExpressionModel baseExpression = null;
                EditableExpressionModel portfolioAdjustmentExpression = null;
                if (resident is BasketCountryModel)
                {
                    var r = resident as BasketCountryModel;
                    basketId       = r.Basket.Id;
                    baseExpression = r.Base;
                    portfolioAdjustmentExpression = r.PortfolioAdjustment;
                }
                if (resident is BasketRegionModel)
                {
                    var r = resident as BasketRegionModel;
                    basketId       = r.Basket.Id;
                    baseExpression = r.Base;
                    portfolioAdjustmentExpression = r.PortfolioAdjustment;
                }

                if (basketId > -1)
                {
                    var requestBaseCommentsCommand = new DelegateCommand(delegate
                    {
                        this.RequestBaseComments(targetingTypeId, basketId);
                    });
                    baseExpression.RegisterForBeingWatched(this, requestBaseCommentsCommand);
                    registeredExpressions.Add(baseExpression);

                    var requestPortfolioAdjustmentCommentsCommand = new DelegateCommand(delegate
                    {
                        this.RequestPortfolioAdjustmentComments(targetingTypeId, portfolioId, basketId);
                    });
                    portfolioAdjustmentExpression.RegisterForBeingWatched(this, requestPortfolioAdjustmentCommentsCommand);
                    registeredExpressions.Add(portfolioAdjustmentExpression);
                }
            }

            this.FinishLoading();
            this.OnGotData();
        }
Example #3
0
 public void Discard()
 {
     this.Residents = null;
     this.Factors   = null;
     this.RootModel = null;
 }