Grouping

We found 10 examples in language CSharp for this search. You will see 46 fragments of code.

Other methods

        /// <summary>
        /// Returns the item scoring the highest in a given list
        /// </summary>
        /// <typeparam name="T">The type of the item to score</typeparam>
        /// <typeparam name="TResult">The score type</typeparam>
        /// <param name="list">The list of items</param>
        /// <param name="scorer">The scoring function</param>
        /// <returns>The item attaining the highest score</returns>
        public static T MaxScored<T, TResult>(this IEnumerable<T> list, Func<T, TResult> scorer) where TResult : IComparable<TResult>
        {
            TResult maxScore = default(TResult);
            T result = default(T);

            foreach (var item in list)
            {
                var score = scorer(item);

                if (score.CompareTo(maxScore) > 0)
                {
                    maxScore = score;
                    result = item;
                }
            }

            return result;
        }

        /// <summary>
        /// Determines whether the specified entity has any of the specified attributes.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="attributes">The attributes to check for.</param>
        /// <returns><c>true</c> if the entity has at least one of the specified attributes, otherwise, <c>false</c></returns>
        public static bool HasAny(this IHaveAttributes entity, AttributeMask attributes)
        {
            return (entity.attributes & attributes) > 0;
        }

        /// <summary>
        /// Determines whether the specified entity has all of the specified attributes.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <param name="attributes">The attributes to check for.</param>
        /// <returns><c>true</c> if the entity has all of the specified attributes, otherwise, <c>false</c></returns>
        public static bool HasAll(this IHaveAttributes entity, AttributeMask attributes)
        {
            return (entity.attributes & attributes) == attributes;
        }

        /// <summary>
        /// Iterates over all members of all groups in the specified grouping.
        /// </summary>
        /// <typeparam name="T">The type grouped</typeparam>
        /// <param name="grouping">The grouping.</param>
        /// <returns>An enumerator</returns>
        public static IEnumerable<T> All<T>(this IGrouping<T> grouping) where T : IGroupable<T>
        {
            var groupCount = grouping.groupCount;
            for (int i = 0; i < groupCount; i++)
            {
                var grp = grouping[i];
                var memberCount = grp.count;
                for (int j = 0; j < memberCount; j++)
                {
                    yield return grp[j];
                }
            }
        }

        /// <summary>
        /// Sets the preferred speed on a grouping.
        /// </summary>
        /// <typeparam name="T">The type grouped</typeparam>
        /// <param name="grouping">The grouping.</param>
        /// <param name="speed">The speed.</param>
        public static void SetPreferredSpeed<T>(this IGrouping<T> grouping, float speed) where T : IGroupable<T>
        {
            var groupCount = grouping.groupCount;
            for (int i = 0; i < groupCount; i++)
            {
                grouping[i].SetPreferredSpeed(speed);
            }
        }

        /// <summary>
        /// Stops the specified grouping.
        /// </summary>
        /// <typeparam name="T">Type of members in the grouping</typeparam>
        /// <param name="grouping">The grouping.</param>
        public static void Stop<T>(this IGrouping<T> grouping) where T : IGroupable<T>
        {
            var groupCount = grouping.groupCount;
            for (int i = 0; i < groupCount; i++)
            {
                grouping[i].Stop();
            }
        }


        /// <summary>
        /// Enum types are equal by primary key
        /// </summary>
        public bool Equals(ProjectWorkflowSectionGrouping other)
        {
            if (other == null)
            {
                return false;
            }
            return other.ProjectWorkflowSectionGroupingID == ProjectWorkflowSectionGroupingID;
        }

        /// <summary>
        /// Enum types are equal by primary key
        /// </summary>
        public override bool Equals(object obj)
        {
            return Equals(obj as ProjectWorkflowSectionGrouping);
        }

        /// <summary>
        /// Enum types are equal by primary key
        /// </summary>
        public override int GetHashCode()
        {
            return ProjectWorkflowSectionGroupingID;
        }

        public static ProjectWorkflowSectionGrouping ToType(int enumValue)
        {
            return ToType((ProjectWorkflowSectionGroupingEnum)enumValue);
        }

        public static ProjectWorkflowSectionGrouping ToType(ProjectWorkflowSectionGroupingEnum enumValue)
        {
            switch (enumValue)
            {
                case ProjectWorkflowSectionGroupingEnum.AdditionalData:
                    return AdditionalData;
                case ProjectWorkflowSectionGroupingEnum.Expenditures:
                    return Expenditures;
                case ProjectWorkflowSectionGroupingEnum.Location:
                    return Location;
                case ProjectWorkflowSectionGroupingEnum.Overview:
                    return Overview;
                case ProjectWorkflowSectionGroupingEnum.PerformanceMeasures:
                    return PerformanceMeasures;
                default:
                    throw new ArgumentException(string.Format("Unable to map Enum: {0}", enumValue));
            }
        }


        [Fact]
        public void GetAllGrouping_ReturnListOfGrouping()
        {
            //Arrange
            _groupRepo.Setup(
                                    repo =>
                                            repo.GetAll<GroupingDto>(
                                                   It.IsAny<Expression<Func<Grouping, bool>>>(),
                                                    It.IsAny<Func<IQueryable<Grouping>, IIncludableQueryable<Grouping, object>>>(),
                                                    It.IsAny<Func<IQueryable<Grouping>, IOrderedQueryable<Grouping>>>(),
                                                    It.IsAny<Expression<Func<Grouping, GroupingDto>>>(),
                                                    It.IsAny<Boolean>())).
                                 Returns(It.IsAny<IEnumerable<GroupingDto>>());

            //Act
            _groupRepo.Object.GetAll<GroupingDto>();

            //Assert
            _groupRepo.Verify(x => x.GetAll<GroupingDto>(
                                                    It.IsAny<Expression<Func<Grouping, bool>>>(),
                                                    It.IsAny<Func<IQueryable<Grouping>, IIncludableQueryable<Grouping, object>>>(),
                                                    It.IsAny<Func<IQueryable<Grouping>, IOrderedQueryable<Grouping>>>(),
                                                    It.IsAny<Expression<Func<Grouping, GroupingDto>>>(),
                                                    It.IsAny<Boolean>()));
        }

        [Fact]
        public void FindGrouping_ReturnGroupingObject()
        {
            //Arrange
            _groupRepo.Setup(
                                    repo =>
                                            repo.Find(It.IsAny<object>())).
                                 Returns(It.IsAny<Grouping>());

            //Act
            _groupRepo.Object.Find(1);

            //Assert
            _groupRepo.Verify(
                                    x => x.Find(
                                                    It.IsAny<object>()));
        }

        [Fact]
        public void FirstOrDefault_ReturnsGrouping_WhenFoundGrupingObject()
        {
            //Arrange
            _groupRepo.Setup(
                                    repo =>
                                            repo.FirstOrDefault(
                                                   It.IsAny<Expression<Func<Grouping, bool>>>(),
                                                    It.IsAny<Func<IQueryable<Grouping>, IIncludableQueryable<Grouping, object>>>(),
                                                    It.IsAny<Boolean>())).
                                 Returns(It.IsAny<Grouping>());

            //Act
            _groupRepo.Object.FirstOrDefault();

            //Assert
            _groupRepo.Verify(x => x.FirstOrDefault(
                                                    It.IsAny<Expression<Func<Grouping, bool>>>(),
                                                    It.IsAny<Func<IQueryable<Grouping>, IIncludableQueryable<Grouping, object>>>(),
                                                    It.IsAny<Boolean>()));
        }

        [Fact]
        public void AddGrouping_ReturnBoolean()
        {
            //Arrange
            _groupRepo.Setup(
                                    repo =>
                                            repo.Add(It.IsAny<Grouping>())).
                                 Returns(It.IsAny<Boolean>());

            //Act
            _groupRepo.Object.Add(new Grouping());

            //Assert
            _groupRepo.Verify(
                                    x => x.Add(
                                                    It.IsAny<Grouping>()));
        }

        [Fact]
        public void UpdateGrouping_ReturnBoolean()
        {
            //Arrange
            _groupRepo.Setup(
                                    repo =>
                                            repo.Update(It.IsAny<Grouping>())).
                                 Returns(It.IsAny<Boolean>());

            //Act
            _groupRepo.Object.Update(new Grouping());

            //Assert
            _groupRepo.Verify(
                                    x => x.Update(
                                                    It.IsAny<Grouping>()));
        }

        [Fact]
        public void RemoveGrouping_ReturnBoolean()
        {
            //Arrange
            _groupRepo.Setup(
                                    repo =>
                                            repo.Remove(It.IsAny<Grouping>())).
                                 Returns(It.IsAny<Boolean>());

            //Act
            _groupRepo.Object.Remove(new Grouping());

            //Assert
            _groupRepo.Verify(
                                    x => x.Remove(
                                                    It.IsAny<Grouping>()));
        }

namespace Explorer.Common
{
    using System.Collections.Generic;
    using System.Collections.Immutable;
    using System.Linq;
    using System.Text.Json;

    using Diffix;
    using Explorer.JsonExtensions;

    public class IndexedGroupingSetsResultMulti<TIndex> : CountableRow
    {
        internal IndexedGroupingSetsResultMulti(ref Utf8JsonReader reader, ImmutableArray<TIndex> groupingLabels)
        {
            int groupingId;
            (groupingId, Values) = reader.ParseMultiGroupingSet(groupingLabels.Length);
            Count = reader.ParseCount();
            CountNoise = reader.ParseCountNoise();

            AllGroupingLabels = groupingLabels;
            ColumnGrouping = new ColumnGrouping(groupingLabels.Length, groupingId);
        }

        public int GroupingId => ColumnGrouping.GroupingId;

        public ImmutableArray<DValue<JsonElement>> Values { get; }

        public long Count { get; }

        public double? CountNoise { get; }

        public IEnumerable<TIndex> GroupingLabels => ColumnGrouping.Indices.Select(i => AllGroupingLabels[i]);

        public ImmutableArray<int> GroupingIndices => ColumnGrouping.Indices;

        public ColumnGrouping ColumnGrouping { get; }

        /// <summary>
        /// Gets a value indicating whether the row should be considered `null`. The row is considered null if *all*
        /// columns are null.
        /// <para>
        /// Rationale:
        /// Null is like nothing.
        /// If all columns have nothing, then the row has nothing.
        /// But if any column has something (not null) then the row has something.
        /// </para>
        /// </summary>
        /// <returns><c>true</c> if all columns are null, otherwise <c>false</c>.</returns>
        public bool IsNull => Values.All(v => v.IsNull);

        /// <summary>
        /// Gets a value indicating whether the row should be considered suppressed. The row is considered suppressed
        /// if *any* column is suppressed.
        /// <para>
        /// Rationale:
        /// Suppressed values are uncertain.
        /// If any column is uncertain than that makes the row uncertain.
        /// Only if all columns are certain (not suppressed) can the row be considered certain.
        /// </para>
        /// </summary>
        /// <returns><c>true</c> if any column is suppressed, otherwise <c>false</c>.</returns>
        public bool IsSuppressed => Values.Any(v => v.IsSuppressed);

        private ImmutableArray<TIndex> AllGroupingLabels { get; }
    }
}

        [Shape]
        public async Task<IHtmlContent> Zone(dynamic DisplayAsync, dynamic Shape)
        {
            var htmlContentBuilder = new HtmlContentBuilder();
            foreach (var item in Shape)
            {
                htmlContentBuilder.AppendHtml(await DisplayAsync(item));
            }

            return htmlContentBuilder;
        }

        [Shape]
        public async Task<IHtmlContent> ContentZone(dynamic DisplayAsync, dynamic Shape, IShapeFactory ShapeFactory)
        {
            var htmlContentBuilder = new HtmlContentBuilder();

            var shapes = ((IEnumerable<dynamic>)Shape);

            var groupings = shapes.GroupBy(x =>
            {
                // By convention all placement delimiters default to the name 'Content' when not specified during placement.
                var key = (string)x.Metadata.Tab;
                if (String.IsNullOrEmpty(key))
                {
                    key = "Content";
                }

                // Remove any positioning modifier.
                var modifierIndex = key.IndexOf(';');
                if (modifierIndex != -1)
                {
                    key = key.Substring(0, modifierIndex);
                }

                return key;
            }).ToList();

            // Process Tabs first, then Cards, then Columns.
            if (groupings.Count > 1)
            {
                var orderedGroupings = groupings.OrderBy(grouping =>
                {
                    var firstGroupWithModifier = grouping.FirstOrDefault(group =>
                    {
                        var key = (string)group.Metadata.Tab;
                        if (!String.IsNullOrEmpty(key))
                        {
                            var modifierIndex = key.IndexOf(';');
                            if (modifierIndex != -1)
                            {
                                return true;
                            }
                        }
                        return false;
                    });

                    if (firstGroupWithModifier != null)
                    {
                        var key = (string)firstGroupWithModifier.Metadata.Tab;
                        var modifierIndex = key.IndexOf(';');
                        return new PositionalGrouping(key.Substring(modifierIndex));
                    }

                    return new PositionalGrouping(null);
                }, FlatPositionComparer.Instance).ToList();

                Shape container = (Shape)await ShapeFactory.CreateAsync("TabContainer", Arguments.From(
                    new
                    {
                        ContentItem = Shape.ContentItem,
                        Grouping = orderedGroupings
                    }));
                foreach (var orderedGrouping in orderedGroupings)
                {
                    Shape groupingShape = (Shape)await ShapeFactory.CreateAsync("Tab", Arguments.From(
                        new
                        {
                            Grouping = orderedGrouping,
                            ContentItem = Shape.ContentItem
                        }));
                    foreach (var item in orderedGrouping)
                    {
                        groupingShape.Add(item);
                    }
                    container.Add(groupingShape);
                }

                htmlContentBuilder.AppendHtml(await DisplayAsync(container));
            }
            else if (groupings.Count == 1)
            {
                // Evaluate for cards.
                var cardGrouping = await ShapeFactory.CreateAsync("CardGrouping", Arguments.From(
                    new
                    {
                        Grouping = groupings[0],
                        ContentItem = Shape.ContentItem
                    }));

                htmlContentBuilder.AppendHtml(await DisplayAsync(cardGrouping));
            }

            return htmlContentBuilder;
        }

        [Shape]
        public async Task<IHtmlContent> CardGrouping(dynamic DisplayAsync, dynamic Shape, IShapeFactory ShapeFactory)
        {
            var htmlContentBuilder = new HtmlContentBuilder();
            IGrouping<string, dynamic> grouping = Shape.Grouping;

            var groupings = grouping.GroupBy(x =>
            {
                // By convention all placement delimiters default to the name 'Content' when not specified during placement.
                var key = (string)x.Metadata.Card;
                if (String.IsNullOrEmpty(key))
                {
                    key = "Content";
                }

                // Remove positional modifier.
                var modifierIndex = key.IndexOf(';');
                if (modifierIndex != -1)
                {
                    key = key.Substring(0, modifierIndex);
                }

                return key;
            }).ToList();

            if (groupings.Count > 1)
            {
                var orderedGroupings = groupings.OrderBy(grouping =>
                {
                    var firstGroupWithModifier = grouping.FirstOrDefault(group =>
                    {
                        var key = (string)group.Metadata.Card;
                        if (!String.IsNullOrEmpty(key))
                        {
                            var modifierIndex = key.IndexOf(';');
                            if (modifierIndex != -1)
                            {
                                return true;
                            }
                        }
                        return false;
                    });

                    if (firstGroupWithModifier != null)
                    {
                        var key = (string)firstGroupWithModifier.Metadata.Card;
                        var modifierIndex = key.IndexOf(';');
                        return new PositionalGrouping(key.Substring(modifierIndex));
                    }

                    return new PositionalGrouping();
                }, FlatPositionComparer.Instance).ToList();

                Shape container = (Shape)await ShapeFactory.CreateAsync("CardContainer", Arguments.From(
                    new
                    {
                        ContentItem = Shape.ContentItem
                    }));
                foreach (var orderedGrouping in orderedGroupings)
                {
                    Shape groupingShape = (Shape)await ShapeFactory.CreateAsync("Card", Arguments.From(
                        new
                        {
                            Grouping = orderedGrouping,
                            ContentItem = Shape.ContentItem
                        }));
                    foreach (var item in orderedGrouping)
                    {
                        groupingShape.Add(item);
                    }
                    container.Add(groupingShape);
                }

                htmlContentBuilder.AppendHtml(await DisplayAsync(container));
            }
            else
            {
                // Evaluate for columns.
                var groupingShape = await ShapeFactory.CreateAsync("ColumnGrouping", Arguments.From(
                    new
                    {
                        Grouping = grouping,
                        ContentItem = Shape.ContentItem
                    }));
                htmlContentBuilder.AppendHtml(await DisplayAsync(groupingShape));
            }

            return htmlContentBuilder;
        }


        [Shape]
        public async Task<IHtmlContent> ColumnGrouping(dynamic DisplayAsync, dynamic Shape, IShapeFactory ShapeFactory)
        {
            var htmlContentBuilder = new HtmlContentBuilder();
            IGrouping<string, dynamic> grouping = Shape.Grouping;

            var groupings = grouping.GroupBy(x =>
            {
                // By convention all placement delimiters default to the name 'Content' when not specified during placement.
                var key = (string)x.Metadata.Column;
                if (String.IsNullOrEmpty(key))
                {
                    key = "Content";
                }

                // Remove column modifier.
                var modifierIndex = key.IndexOf('_');
                if (modifierIndex != -1)
                {
                    key = key.Substring(0, modifierIndex);
                }

                // Remove positional modifier.
                modifierIndex = key.IndexOf(';');
                if (modifierIndex != -1)
                {
                    key = key.Substring(0, modifierIndex);
                }

                return key;
            }).ToList();

            if (groupings.Count > 1)
            {
                var positionModifiers = GetColumnPositions(groupings);

                var orderedGroupings = groupings.OrderBy(grouping =>
                {
                    if (positionModifiers.TryGetValue(grouping.Key, out var position))
                    {
                        return new PositionalGrouping { Position = position };
                    }
                    else
                    {
                        return new PositionalGrouping();
                    }
                }, FlatPositionComparer.Instance).ToList();

                var columnModifiers = GetColumnModifiers(orderedGroupings);

                Shape container = (Shape)await ShapeFactory.CreateAsync("ColumnContainer", Arguments.From(
                    new
                    {
                        ContentItem = Shape.ContentItem
                    }));
                foreach (var orderedGrouping in orderedGroupings)
                {
                    Shape groupingShape = (Shape)await ShapeFactory.CreateAsync("Column", Arguments.From(
                        new
                        {
                            Grouping = orderedGrouping,
                            ContentItem = Shape.ContentItem
                        }));
                    groupingShape.Classes.Add("ta-col-grouping");
                    groupingShape.Classes.Add("column-" + orderedGrouping.Key.HtmlClassify());

                    // To adjust this breakpoint apply a modifier of lg-3 to every column.
                    var columnClasses = "col-12 col-md";
                    if (columnModifiers.TryGetValue(orderedGrouping.Key, out var columnModifier))
                    {
                        // When the modifier also has a - assume it is providing a breakpointed class.
                        if (columnModifier.IndexOf('-') != -1)
                        {
                            columnClasses = "col-12 col-" + columnModifier;
                        }
                        else // Otherwise assume a default md breakpoint.
                        {
                            columnClasses = "col-12 col-md-" + columnModifier;
                        }
                    }

                    groupingShape.Classes.Add(columnClasses);

                    foreach (var item in orderedGrouping)
                    {
                        groupingShape.Add(item);
                    }
                    container.Add(groupingShape);
                }

                htmlContentBuilder.AppendHtml(await DisplayAsync(container));
            }
            else
            {
                foreach (var item in grouping)
                {
                    htmlContentBuilder.AppendHtml(await DisplayAsync(item));
                }
            }

            return htmlContentBuilder;
        }
        private static Dictionary<string, string> GetColumnPositions(IList<IGrouping<string, dynamic>> groupings)
        {
            var positionModifiers = new Dictionary<string, string>();
            foreach (var grouping in groupings)
            {
                var firstGroupWithModifier = FirstGroupingWithModifierOrDefault(grouping, ';');
                if (firstGroupWithModifier != null)
                {
                    var key = (string)firstGroupWithModifier.Metadata.Column;
                    var columnModifierIndex = key.IndexOf('_');
                    if (columnModifierIndex != -1)
                    {
                        var positionModifierIndex = key.IndexOf(';');
                        // Column-9;56
                        if (positionModifierIndex > columnModifierIndex)
                        {
                            positionModifiers.Add(key.Substring(0, columnModifierIndex), key.Substring(positionModifierIndex + 1));
                        }
                        else // Column;56-9
                        {
                            var length = columnModifierIndex - positionModifierIndex;
                            positionModifiers.Add(key.Substring(0, positionModifierIndex), key.Substring(positionModifierIndex + 1, length - 1));
                        }
                    }
                    else
                    {
                        var positionModifierIndex = key.IndexOf(';');
                        positionModifiers.Add(key.Substring(0, positionModifierIndex), key.Substring(positionModifierIndex + 1));
                    }
                }
            }

            return positionModifiers;
        }

        private static Dictionary<string, string> GetColumnModifiers(IList<IGrouping<string, dynamic>> groupings)
        {
            var columnModifiers = new Dictionary<string, string>();
            foreach (var grouping in groupings)
            {
                var firstGroupWithModifier = FirstGroupingWithModifierOrDefault(grouping, '_');
                if (firstGroupWithModifier != null)
                {
                    var key = (string)firstGroupWithModifier.Metadata.Column;
                    var posModifierIndex = key.IndexOf(';');
                    if (posModifierIndex != -1)
                    {
                        var colModifierIndex = key.IndexOf('_');
                        // Column;5.1_9
                        if (colModifierIndex > posModifierIndex)
                        {
                            columnModifiers.Add(key.Substring(0, posModifierIndex), key.Substring(colModifierIndex + 1));
                        }
                        else // Column_9;5.1
                        {
                            var length = posModifierIndex - colModifierIndex;
                            columnModifiers.Add(key.Substring(0, colModifierIndex), key.Substring(colModifierIndex + 1, length - 1));
                        }
                    }
                    else
                    {
                        var columnModifierIndex = key.IndexOf('_');
                        columnModifiers.Add(key.Substring(0, columnModifierIndex), key.Substring(columnModifierIndex + 1));
                    }
                }
            }

            return columnModifiers;
        }


		#endregion

		#region Methods

		/// <summary>
		/// SupportByVersion OWC10 1
		/// 
		/// </summary>
		/// <param name="groupingDefName">string GroupingDefName</param>
		/// <param name="groupingFieldName">string GroupingFieldName</param>
		/// <param name="pageFieldName">string PageFieldName</param>
		/// <param name="index">optional object Index</param>
		[SupportByVersionAttribute("OWC10", 1)]
		public NetOffice.OWC10Api.GroupingDef Add(string groupingDefName, string groupingFieldName, string pageFieldName, object index)
		{
			object[] paramsArray = Invoker.ValidateParamsArray(groupingDefName, groupingFieldName, pageFieldName, index);
			object returnItem = Invoker.MethodReturn(this, "Add", paramsArray);
			NetOffice.OWC10Api.GroupingDef newObject = Factory.CreateKnownObjectFromComProxy(this, returnItem,NetOffice.OWC10Api.GroupingDef.LateBindingApiWrapperType) as NetOffice.OWC10Api.GroupingDef;
			return newObject;
		}

		/// <summary>
		/// SupportByVersion OWC10 1
		/// 
		/// </summary>
		/// <param name="groupingDefName">string GroupingDefName</param>
		/// <param name="groupingFieldName">string GroupingFieldName</param>
		/// <param name="pageFieldName">string PageFieldName</param>
		[CustomMethodAttribute]
		[SupportByVersionAttribute("OWC10", 1)]
		public NetOffice.OWC10Api.GroupingDef Add(string groupingDefName, string groupingFieldName, string pageFieldName)
		{
			object[] paramsArray = Invoker.ValidateParamsArray(groupingDefName, groupingFieldName, pageFieldName);
			object returnItem = Invoker.MethodReturn(this, "Add", paramsArray);
			NetOffice.OWC10Api.GroupingDef newObject = Factory.CreateKnownObjectFromComProxy(this, returnItem,NetOffice.OWC10Api.GroupingDef.LateBindingApiWrapperType) as NetOffice.OWC10Api.GroupingDef;
			return newObject;
		}

		/// <summary>
		/// SupportByVersion OWC10 1
		/// 
		/// </summary>
		/// <param name="groupingDefName">string GroupingDefName</param>
		/// <param name="groupingFieldName">string GroupingFieldName</param>
		/// <param name="pageFieldName">string PageFieldName</param>
		/// <param name="totalType">NetOffice.OWC10Api.Enums.DscTotalTypeEnum TotalType</param>
		/// <param name="index">optional object Index</param>
		[SupportByVersionAttribute("OWC10", 1)]
		public NetOffice.OWC10Api.GroupingDef AddTotal(string groupingDefName, string groupingFieldName, string pageFieldName, NetOffice.OWC10Api.Enums.DscTotalTypeEnum totalType, object index)
		{
			object[] paramsArray = Invoker.ValidateParamsArray(groupingDefName, groupingFieldName, pageFieldName, totalType, index);
			object returnItem = Invoker.MethodReturn(this, "AddTotal", paramsArray);
			NetOffice.OWC10Api.GroupingDef newObject = Factory.CreateKnownObjectFromComProxy(this, returnItem,NetOffice.OWC10Api.GroupingDef.LateBindingApiWrapperType) as NetOffice.OWC10Api.GroupingDef;
			return newObject;
		}

		/// <summary>
		/// SupportByVersion OWC10 1
		/// 
		/// </summary>
		/// <param name="groupingDefName">string GroupingDefName</param>
		/// <param name="groupingFieldName">string GroupingFieldName</param>
		/// <param name="pageFieldName">string PageFieldName</param>
		/// <param name="totalType">NetOffice.OWC10Api.Enums.DscTotalTypeEnum TotalType</param>
		[CustomMethodAttribute]
		[SupportByVersionAttribute("OWC10", 1)]
		public NetOffice.OWC10Api.GroupingDef AddTotal(string groupingDefName, string groupingFieldName, string pageFieldName, NetOffice.OWC10Api.Enums.DscTotalTypeEnum totalType)
		{
			object[] paramsArray = Invoker.ValidateParamsArray(groupingDefName, groupingFieldName, pageFieldName, totalType);
			object returnItem = Invoker.MethodReturn(this, "AddTotal", paramsArray);
			NetOffice.OWC10Api.GroupingDef newObject = Factory.CreateKnownObjectFromComProxy(this, returnItem,NetOffice.OWC10Api.GroupingDef.LateBindingApiWrapperType) as NetOffice.OWC10Api.GroupingDef;
			return newObject;
		}

		/// <summary>
		/// SupportByVersion OWC10 1
		/// 
		/// </summary>
		/// <param name="index">object Index</param>
		[SupportByVersionAttribute("OWC10", 1)]
		public void Delete(object index)
		{
			object[] paramsArray = Invoker.ValidateParamsArray(index);
			Invoker.Method(this, "Delete", paramsArray);
		}

		#endregion

       #region IEnumerable<NetOffice.OWC10Api.GroupingDef> Member
        
        /// <summary>
		/// SupportByVersionAttribute OWC10, 1
		/// </summary>
		[SupportByVersionAttribute("OWC10", 1)]
       public IEnumerator<NetOffice.OWC10Api.GroupingDef> GetEnumerator()  
       {
           NetRuntimeSystem.Collections.IEnumerable innerEnumerator = (this as NetRuntimeSystem.Collections.IEnumerable);
           foreach (NetOffice.OWC10Api.GroupingDef item in innerEnumerator)
               yield return item;
       }


        public IList<Grouping> GetUniqueGroupings()
        {
            _uniqueGroupings = new List<Grouping>();

            var idToGroupings = GetMapOfUniqueIdToGroupings();

            // Create unique groupings
            foreach (var idToGrouping in idToGroupings)
            {
                var groupings = idToGrouping.Value;
                var grouping = groupings.First();
                _uniqueGroupings.Add(grouping);

                if (groupings.Count > 1)
                {
                    var sortedGroupings = new GroupingSorter(groupings)
                        .SortByDataPointTimePeriodMostRecentFirst().ToList();

                    // Use overall earliest timepoint
                    var earliestGrouping = sortedGroupings.Last();
                    grouping.BaselineYear = earliestGrouping.BaselineYear;
                    grouping.BaselineQuarter = earliestGrouping.BaselineQuarter;
                    grouping.BaselineMonth = earliestGrouping.BaselineMonth;

                    // Use overall latest timepoint
                    var latestGrouping = sortedGroupings.First();
                    grouping.DataPointYear = latestGrouping.DataPointYear;
                    grouping.DataPointQuarter = latestGrouping.DataPointQuarter;
                    grouping.DataPointMonth = latestGrouping.DataPointMonth;

                    // Use most popular polarity
                    grouping.PolarityId = new GroupingSorter(groupings).GetMostCommonPolarityId();
                }
            }

            return _uniqueGroupings;
        }

        private Dictionary<string, List<Grouping>> GetMapOfUniqueIdToGroupings()
        {
            var idToGroupings = new Dictionary<string, List<Grouping>>();
            foreach (Grouping grouping in _groupings)
            {
                string idString = GetGroupingIdString(grouping);
                if (idToGroupings.ContainsKey(idString) == false)
                {
                    idToGroupings[idString] = new List<Grouping>();
                }

                idToGroupings[idString].Add(grouping);
            }
            return idToGroupings;
        }

        private static string GetGroupingIdString(Grouping grouping)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(grouping.IndicatorId);
            sb.Append("-");
            sb.Append(grouping.SexId);
            sb.Append("-");
            sb.Append(grouping.AgeId);
            sb.Append("-");
            sb.Append(grouping.ComparatorId);
            sb.Append("-");
            sb.Append(grouping.AreaTypeId);
            sb.Append("-");
            sb.Append(grouping.YearRange);
            return sb.ToString();
        }

namespace Explorer.Common
{
    using System.Collections.Immutable;
    using System.Text.Json;

    using Diffix;
    using Explorer.JsonExtensions;

    public class IndexedGroupingSetsResult<TIndex, TGroupedValue> : CountableRow
    {
        internal IndexedGroupingSetsResult(ref Utf8JsonReader reader, ImmutableArray<TIndex> groupingLabels)
        {
            GroupingLabels = groupingLabels;
            (GroupingId, DValue) = reader.ParseGroupingSet<TGroupedValue>(groupingLabels.Length);
            Count = reader.ParseCount();
            CountNoise = reader.ParseCountNoise();
        }

        public int GroupingId { get; }

        public TGroupedValue Value => DValue.Value;

        public long Count { get; }

        public double? CountNoise { get; }

        public ImmutableArray<TIndex> GroupingLabels { get; }

        public TIndex GroupingLabel => GroupingLabels[GroupingIndex];

        public int GroupSize => GroupingLabels.Length;

        public int GroupingIndex =>
            GroupingIdConverter.GetConverter(GroupSize).SingleIndexFromGroupingId(GroupingId);

        public bool IsNull => DValue.IsNull;

        public bool IsSuppressed => DValue.IsSuppressed;

        public bool HasValue => DValue.HasValue;

        protected DValue<TGroupedValue> DValue { get; }
    }
}

        public IHtmlNode CreateGroupHeader(GridGroupingData groupingData)
        {
            var div = new HtmlElement("div").AddClass("k-grouping-header");

            if (groupingData.GroupDescriptors.Any())
            {
                AppendGroupIndicators(div, groupingData);
            }
            else
            {
                AppendHint(div, groupingData);
            }
            
            return div;
        }

        private void AppendHint(IHtmlNode div, GridGroupingData groupingData)
        {
            div.Html(groupingData.Messages.Empty);
        }

        private void AppendGroupIndicators(IHtmlNode div, GridGroupingData groupingData)
        {
            var groupDescriptors = groupingData.GroupDescriptors;
            
            foreach (var group in groupDescriptors)
            {
                AppendGroupIndicator(div, group, groupingData);
            }
        }
        
        private void AppendGroupIndicator(IHtmlNode div, GroupDescriptor group, GridGroupingData groupingData)
        {
            var groups = new List<GroupDescriptor>(groupingData.GroupDescriptors);

            var indicator = new HtmlElement("div").AddClass(UIPrimitives.Grid.GroupIndicator);

            indicator.Attribute("data-field", group.Member)
                .Attribute("data-dir", group.SortDirection == ListSortDirection.Ascending ? "asc" : "desc")
                .Attribute("data-title", groupingData.GetTitle(group.Member));

            indicator.AppendTo(div);

            AppendSortLink(indicator, group, groups, groupingData.UrlBuilder, groupingData.GetTitle);

            AppendUngroupButton(indicator, groupingData.UrlBuilder, groups);
        }
        
        private void AppendUngroupButton(IHtmlNode indicator, IGridUrlBuilder urlBuilder, List<GroupDescriptor> groups)
        {
            var button = new HtmlElement("a")
                            .Attribute("href", urlBuilder.SelectUrl(GridUrlParameters.Group,
                                    GridDescriptorSerializer.Serialize(groups)))
                            .AddClass(new[] { UIPrimitives.Button, UIPrimitives.ButtonIcon, UIPrimitives.ButtonBare })
                            .AppendTo(indicator);

            new HtmlElement("span")
                .AddClass(UIPrimitives.Icon, UIPrimitives.Icons.GroupDelete)
                .AppendTo(button);
        }

        private void AppendSortLink(IHtmlNode indicator, GroupDescriptor group, List<GroupDescriptor> groups, IGridUrlBuilder urlBuilder, Func<string, string> title)
        {
            group.CycleSortDirection();

            var a = new HtmlElement("a")
                 .AddClass(UIPrimitives.Link)
                 .Attribute("href", urlBuilder.SelectUrl(GridUrlParameters.Group, GridDescriptorSerializer.Serialize(groups)))
                 .AppendTo(indicator);

            group.CycleSortDirection();

            new HtmlElement("span")
                .AddClass(UIPrimitives.Icon)
                .ToggleClass("k-si-arrow-n", group.SortDirection == ListSortDirection.Ascending)
                .ToggleClass("k-si-arrow-s", group.SortDirection == ListSortDirection.Descending)
                .AppendTo(a);

            groups.Remove(group);

            new TextNode(title(group.Member)).AppendTo(a);
        }


		public override void Initialize(Model.NodeData data) {
			m_groupingKeyword = new SerializableMultiTargetString(Model.Settings.GROUPING_KEYWORD_DEFAULT);
			m_patternType = new SerializableMultiTargetInt((int)GroupingPatternType.WildCard);
			m_allowSlash = false;
            m_groupNameFormat = new SerializableMultiTargetString();

			data.AddDefaultInputPoint();
			data.AddDefaultOutputPoint();
		}

		public void Import(V1.NodeData v1, Model.NodeData v2) {
			m_groupingKeyword = new SerializableMultiTargetString(v1.GroupingKeywords);
			m_patternType = new SerializableMultiTargetInt((int)GroupingPatternType.WildCard);
			m_allowSlash = true;
            m_groupNameFormat = new SerializableMultiTargetString();
		}

		public override Node Clone(Model.NodeData newData) {
			var newNode = new Grouping();
			newNode.m_groupingKeyword = new SerializableMultiTargetString(m_groupingKeyword);
			newNode.m_patternType = new SerializableMultiTargetInt(m_patternType);
			newNode.m_allowSlash = m_allowSlash;
            newNode.m_groupNameFormat = new SerializableMultiTargetString(m_groupNameFormat);

			newData.AddDefaultInputPoint();
			newData.AddDefaultOutputPoint();
			return newNode;
		}

		public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged) {

			if (m_groupingKeyword == null) {
				return;
			}

			EditorGUILayout.HelpBox("Group By File Path: Create group of assets from asset's file path.", MessageType.Info);
			editor.UpdateNodeName(node);

			GUILayout.Space(10f);
			var newSlash = EditorGUILayout.ToggleLeft("Allow directory separator ('/') in group name", m_allowSlash);
			if(newSlash != m_allowSlash) {
				using(new RecordUndoScope("Change Allow Slash Setting", node, true)){
					m_allowSlash = newSlash;
					onValueChanged();
				}
			}
			if(m_allowSlash) {
				EditorGUILayout.HelpBox("Allowing directory separator for group name may create incompatible group name with other nodes. Please use this option carefully.", MessageType.Info);
			}
			GUILayout.Space(4f);

			//Show target configuration tab
			editor.DrawPlatformSelector(node);
			using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
				var disabledScope = editor.DrawOverrideTargetToggle(node, m_groupingKeyword.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
					using(new RecordUndoScope("Remove Target Grouping Keyword Settings", node, true)){
						if(enabled) {
							m_groupingKeyword[editor.CurrentEditingGroup] = m_groupingKeyword.DefaultValue;
							m_patternType[editor.CurrentEditingGroup] = m_patternType.DefaultValue;
                            m_groupNameFormat[editor.CurrentEditingGroup] = m_groupNameFormat.DefaultValue;
						} else {
							m_groupingKeyword.Remove(editor.CurrentEditingGroup);
							m_patternType.Remove(editor.CurrentEditingGroup);
                            m_groupNameFormat.Remove(editor.CurrentEditingGroup);
						}
						onValueChanged();
					}
				});

				using (disabledScope) {
					var newType = (GroupingPatternType)EditorGUILayout.EnumPopup("Pattern Type",(GroupingPatternType)m_patternType[editor.CurrentEditingGroup]);
					if (newType != (GroupingPatternType)m_patternType[editor.CurrentEditingGroup]) {
						using(new RecordUndoScope("Change Grouping Pattern Type", node, true)){
							m_patternType[editor.CurrentEditingGroup] = (int)newType;
							onValueChanged();
						}
					}

					var newGroupingKeyword = EditorGUILayout.TextField("Grouping Keyword",m_groupingKeyword[editor.CurrentEditingGroup]);
					string helpText = null;
					switch((GroupingPatternType)m_patternType[editor.CurrentEditingGroup]) {
					case GroupingPatternType.WildCard:
						helpText = "Grouping Keyword requires \"*\" in itself. It assumes there is a pattern such as \"ID_0\" in incoming paths when configured as \"ID_*\" ";
						break;
					case GroupingPatternType.RegularExpression:
						helpText = "Grouping Keyword requires pattern definition with \"()\" in Regular Expression manner.";
						break;
					}
					EditorGUILayout.HelpBox(helpText, MessageType.Info);

					if (newGroupingKeyword != m_groupingKeyword[editor.CurrentEditingGroup]) {
						using(new RecordUndoScope("Change Grouping Keywords", node, true)){
							m_groupingKeyword[editor.CurrentEditingGroup] = newGroupingKeyword;
							onValueChanged();
						}
					}

                    var newGroupNameFormat = EditorGUILayout.TextField("Group Name Format",m_groupNameFormat[editor.CurrentEditingGroup]);
                    EditorGUILayout.HelpBox(
                        "You can customize group name. You can use variable {OldGroup} for old group name and {NewGroup} for current matching name.", 
                        MessageType.Info);

                    if (newGroupNameFormat != m_groupNameFormat[editor.CurrentEditingGroup]) {
                        using(new RecordUndoScope("Change Group Name", node, true)){
                            m_groupNameFormat[editor.CurrentEditingGroup] = newGroupNameFormat;
                            onValueChanged();
                        }
                    }
				}
			}
		}

		public override void Prepare (BuildTarget target, 
			Model.NodeData node, 
			IEnumerable<PerformGraph.AssetGroups> incoming, 
			IEnumerable<Model.ConnectionData> connectionsToOutput, 
			PerformGraph.Output Output) 
		{
			GroupingOutput(target, node, incoming, connectionsToOutput, Output);
		}

		private void GroupingOutput (BuildTarget target, 
			Model.NodeData node, 
			IEnumerable<PerformGraph.AssetGroups> incoming, 
			IEnumerable<Model.ConnectionData> connectionsToOutput, 
			PerformGraph.Output Output) 
		{

			ValidateGroupingKeyword(
				m_groupingKeyword[target],
				(GroupingPatternType)m_patternType[target],
				() => {
					throw new NodeException("Grouping Keyword can not be empty.", "Set valid grouping keyword.",node);
				},
				() => {
                    throw new NodeException(String.Format("Grouping Keyword must contain {0} for numbering: currently {1}", Model.Settings.KEYWORD_WILDCARD, m_groupingKeyword[target]),
                        string.Format("Add {0} to the grouping keyword.", Model.Settings.KEYWORD_WILDCARD), node);
				}
			);

			if(connectionsToOutput == null || Output == null) {
				return;
			}

			var outputDict = new Dictionary<string, List<AssetReference>>();

			if(incoming != null) {
				Regex regex = null;
				switch((GroupingPatternType)m_patternType[target]) {
				case GroupingPatternType.WildCard: 
					{
						var groupingKeyword = m_groupingKeyword[target];
						var split = groupingKeyword.Split(Model.Settings.KEYWORD_WILDCARD);
						var groupingKeywordPrefix  = split[0];
						var groupingKeywordPostfix = split[1];
						regex = new Regex(groupingKeywordPrefix + "(.*?)" + groupingKeywordPostfix);
					}
					break;
				case GroupingPatternType.RegularExpression:
					{
						regex = new Regex(m_groupingKeyword[target]);
					}
					break;
				}

				foreach(var ag in incoming) {
                    foreach (var g in ag.assetGroups.Keys) {
                        var assets = ag.assetGroups [g];
						foreach(var a in assets) {
							var targetPath = a.path;

							var match = regex.Match(targetPath);

							if (match.Success) {
								var newGroupingKey = match.Groups[1].Value;
                                if (!string.IsNullOrEmpty (m_groupNameFormat [target])) {
                                    newGroupingKey = m_groupNameFormat [target]
                                        .Replace ("{NewGroup}", newGroupingKey)
                                        .Replace ("{OldGroup}", g);
                                }

								if(!m_allowSlash && newGroupingKey.Contains("/")) {
									throw new NodeException(String.Format("Grouping Keyword with directory separator('/') found: \"{0}\" from asset: {1}", 
										newGroupingKey, targetPath), 
                                        "Remove directory separator from grouping keyword, or enable 'Allow directory separator ('/') in group name' option.", node);
								}

								if (!outputDict.ContainsKey(newGroupingKey)) {
									outputDict[newGroupingKey] = new List<AssetReference>();
								}
								outputDict[newGroupingKey].Add(a);
							}
						}
					}
				}
			}

			var dst = (connectionsToOutput == null || !connectionsToOutput.Any())? 
				null : connectionsToOutput.First();
			Output(dst, outputDict);
		}

DocumentFormat.OpenXml.Drawing.Charts.Grouping : IEnumerable

Constructors :

public Grouping()

Methods :

public EnumValue<GroupingValues> get_Val()
public Void set_Val(EnumValue<GroupingValues> value = )
public OpenXmlElement CloneNode(Boolean deep = )
public Boolean get_HasChildren()
public String get_InnerXml()
public Void set_InnerXml(String value = )
public Void RemoveAllChildren()
public T ReplaceChild(OpenXmlElement newChild = , T oldChild = )
public Void RemoveAllChildren()
public Void Remove()
public Boolean IsAfter(OpenXmlElement element = )
public Boolean IsBefore(OpenXmlElement element = )
public Void AddAnnotation(Object annotation = )
public T Annotation()
public Object Annotation(Type type = )
public IEnumerable<T> Annotations()
public IEnumerable<Object> Annotations(Type type = )
public Void RemoveAnnotations()
public Void RemoveAnnotations(Type type = )
public IEnumerator<OpenXmlElement> GetEnumerator()
public Object Clone()
public MarkupCompatibilityAttributes get_MCAttributes()
public Void set_MCAttributes(MarkupCompatibilityAttributes value = )
public String LookupNamespace(String prefix = )
public String LookupPrefix(String namespaceUri = )
public IFeatureCollection get_Features()
public OpenXmlElementContext get_OpenXmlElementContext()
public OpenXmlElement get_FirstChild()
public OpenXmlElement get_LastChild()
public Boolean get_HasAttributes()
public IEnumerable<OpenXmlAttribute> get_ExtendedAttributes()
public OpenXmlElementList get_ChildElements()
public OpenXmlElement get_Parent()
public String get_NamespaceUri()
public String get_LocalName()
public String get_Prefix()
public IEnumerable<KeyValuePair<StringString>> get_NamespaceDeclarations()
public XmlQualifiedName get_XmlQualifiedName()
public XName get_XName()
public String get_InnerText()
public String get_OuterXml()
public OpenXmlAttribute GetAttribute(String localName = , String namespaceUri = )
public IList<OpenXmlAttribute> GetAttributes()
public Void SetAttribute(OpenXmlAttribute openXmlAttribute = )
public Void RemoveAttribute(String localName = , String namespaceUri = )
public Void SetAttributes(IEnumerable<OpenXmlAttribute> openXmlAttributes = )
public Void ClearAllAttributes()
public Void AddNamespaceDeclaration(String prefix = , String uri = )
public Void RemoveNamespaceDeclaration(String prefix = )
public T GetFirstChild()
public OpenXmlElement PreviousSibling()
public T PreviousSibling()
public OpenXmlElement NextSibling()
public T NextSibling()
public IEnumerable<OpenXmlElement> Ancestors()
public IEnumerable<T> Ancestors()
public IEnumerable<T> Elements()
public IEnumerable<OpenXmlElement> Elements()
public IEnumerable<T> Descendants()
public IEnumerable<OpenXmlElement> Descendants()
public IEnumerable<OpenXmlElement> ElementsBefore()
public IEnumerable<OpenXmlElement> ElementsAfter()
public Void WriteTo(XmlWriter xmlWriter = )
public Void Append(IEnumerable<OpenXmlElement> newChildren = )
public Void Append(OpenXmlElement[] newChildren = )
public T AppendChild(T newChild = )
public T InsertAfter(T newChild = , OpenXmlElement referenceChild = )
public T InsertBefore(T newChild = , OpenXmlElement referenceChild = )
public T InsertAfterSelf(T newElement = )
public T InsertBeforeSelf(T newElement = )
public T InsertAt(T newChild = , Int32 index = )
public T PrependChild(T newChild = )
public T RemoveChild(T oldChild = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()