示例#1
0
        public List <SecurityBucket> CreateSecurityBucket(List <Security> securities, SecurityBucket parentSecurityBucket)
        {
            List <SecurityBucket> securityBuckets = new List <SecurityBucket>();

            foreach (var hierarchyNode in _hierarchy.HierarchyNodes)
            {
                var filteredSecurities = securities.AsQueryable().Where(hierarchyNode.Condition);

                var groupBysSecurities = filteredSecurities.AsQueryable().GroupBy("new(PortUID)", "it");

                foreach (var groupBySecurities in groupBysSecurities.Cast <IGrouping <DynamicClass, Security> >().Select(s => s))
                {
                    SecurityBucket securityBucket = new SecurityBucket();
                    securityBucket.ParentSecurityBucket = parentSecurityBucket;
                    securityBucket.Securities           = groupBySecurities.ToList();
                    securityBucket.PortUID = ((dynamic)groupBySecurities.Key).PortUID;
                    securityBucket.Name    = hierarchyNode.Name;

                    if (_securityBucketFactory != null)
                    {
                        securityBucket.ChildrenSecurityBucket = _securityBucketFactory.CreateSecurityBucket(securityBucket.Securities, securityBucket);
                    }

                    securityBuckets.Add(securityBucket);
                }
            }

            return(securityBuckets);
        }
示例#2
0
        public List <SecurityBucket> CreateSecurityBucket(List <Security> securities, SecurityBucket parentSecurityBucket)
        {
            List <SecurityBucket> securityBuckets = new List <SecurityBucket>();

            var groupBysSecurities = securities.AsQueryable().GroupBy("new(PortUID, " + _groupBy + ")", "it");

            foreach (var groupBySecurities in groupBysSecurities.Cast <IGrouping <DynamicClass, Security> >().Select(s => s))
            {
                SecurityBucket securityBucket = new SecurityBucket();
                securityBucket.ParentSecurityBucket = parentSecurityBucket;
                securityBucket.Securities           = groupBySecurities.ToList();
                securityBucket.PortUID = ((dynamic)groupBySecurities.Key).PortUID;
                securityBucket.Name    = groupBySecurities.Key.GetType().GetProperty(_groupBy).GetValue(groupBySecurities.Key, null).ToString();

                if (_securityBucketFactory != null)
                {
                    securityBucket.ChildrenSecurityBucket = _securityBucketFactory.CreateSecurityBucket(securityBucket.Securities, securityBucket);
                }

                securityBuckets.Add(securityBucket);
            }

            return(securityBuckets);
        }