Exemple #1
0
        private void AddGroup(
            List <ISectionInformation> groupInformation,
            List <string> groupNames, string[] groupNamesArray,
            int currentIndex, object group, string groupingField)
        {
            List <object> groupValues = new List <object>();

            foreach (var name in groupNames)
            {
                var val = group.GetPropertyValue(name);
                groupValues.Add(val);
            }
            var groupCount = 0;

            var countVal = group.GetPropertyValue(groupingField);

            if (countVal != null)
            {
                groupCount = Convert.ToInt32(countVal);
            }
            DefaultSectionInformation groupInfo = new DefaultSectionInformation(
                currentIndex,
                currentIndex + (groupCount - 1),
                groupNamesArray,
                groupValues.ToArray());

            groupInformation.Add(groupInfo);
        }
        private void AddGroup(
            List <ISectionInformation> groupInformation,
            List <string> groupNames, string[] groupNamesArray,
            int currentIndex, object group, string groupingField)
        {
            List <object> groupValues = new List <object>();

            foreach (var name in groupNames)
            {
                FastReflectionHelper helper;
                if (!_groupHelpers.TryGetValue(name, out helper))
                {
                    helper = new FastReflectionHelper();
                    helper.PropertyName = name;
                    _groupHelpers[name] = helper;
                }

                var val = helper.GetPropertyValue(group);
                groupValues.Add(val);
            }
            var groupCount = 0;

            FastReflectionHelper countHelper;

            if (!_groupHelpers.TryGetValue(groupingField, out countHelper))
            {
                countHelper = new FastReflectionHelper();
                countHelper.PropertyName     = groupingField;
                _groupHelpers[groupingField] = countHelper;
            }

            var countVal = countHelper.GetPropertyValue(group);

            if (countVal != null)
            {
                groupCount = Convert.ToInt32(countVal);
            }
            DefaultSectionInformation groupInfo = new DefaultSectionInformation(
                currentIndex,
                currentIndex + (groupCount - 1),
                groupNamesArray,
                groupValues.ToArray());

            groupInformation.Add(groupInfo);
        }