Grouping

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

		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 Initialize(Model.NodeData data) {
			m_groupingPattern = new SerializableMultiTargetString(Model.Settings.GROUPING_KEYWORD_DEFAULT);
			m_patternType = new SerializableMultiTargetInt((int)GroupingPatternType.WildCard);
			m_allowSlash = false;

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

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

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

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

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

			if (m_groupingPattern == 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_groupingPattern.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
					using(new RecordUndoScope("Remove Target Grouping Keyword Settings", node, true)){
						if(enabled) {
							m_groupingPattern[editor.CurrentEditingGroup] = m_groupingPattern.DefaultValue;
							m_patternType[editor.CurrentEditingGroup] = m_patternType.DefaultValue;
						} else {
							m_groupingPattern.Remove(editor.CurrentEditingGroup);
							m_patternType.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_groupingPattern[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_groupingPattern[editor.CurrentEditingGroup]) {
						using(new RecordUndoScope("Change Grouping Keywords", node, true)){
							m_groupingPattern[editor.CurrentEditingGroup] = newGroupingKeyword;
							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_groupingPattern[target],
				(GroupingPatternType)m_patternType[target],
				() => {
					throw new NodeException("Grouping Keyword can not be empty.", node.Id);
				},
				() => {
					throw new NodeException(String.Format("Grouping Keyword must contain {0} for numbering: currently {1}", Model.Settings.KEYWORD_WILDCARD, m_groupingPattern[target]), node.Id);
				}
			);

			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_groupingPattern[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_groupingPattern[target]);
					}
					break;
				}

				foreach(var ag in incoming) {
					foreach (var assets in ag.assetGroups.Values) {
						foreach(var a in assets) {
							var targetPath = a.path;

							var match = regex.Match(targetPath);

							if (match.Success) {
								var newGroupingKey = match.Groups[1].Value;

								if(!m_allowSlash && newGroupingKey.Contains("/")) {
									throw new NodeException(String.Format("Grouping Keyword with directory separator('/') found: \"{0}\" from asset: {1}", 
										newGroupingKey, targetPath), node.Id);
								}

								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);
		}


        /// <summary>
        /// Adds <paramref name="element"/> under the specified <paramref name="key"/>. <paramref name="key"/> does not need to exist.
        /// </summary>
        /// <param name="key">The key to add <paramref name="element"/> under.</param>
        /// <param name="element">The element to add.</param>
        public void Add(TKey key, TElement element)
        {
            MutableLookupGrouping grouping;
            if (key == null)
                grouping = nullGrouping;
            else if (!groupings.TryGetValue(key, out grouping))
            {
                grouping = new MutableLookupGrouping(key);
                groupings.Add(key, grouping);
            }

            grouping.Add(element);
        }

        public void Add(TKey key, IEnumerable<TElement> elements)
        {
            if (elements == null)
                throw new ArgumentNullException("elements");

            MutableLookupGrouping grouping;
            if (key == null)
                grouping = nullGrouping;
            else if (!groupings.TryGetValue(key, out grouping))
            {
                grouping = new MutableLookupGrouping(key);
                groupings.Add(key, grouping);
            }

            grouping.AddRange(elements);
        }

        /// <summary>
        /// Removes <paramref name="element"/> from the <paramref name="key"/>.
        /// </summary>
        /// <param name="key">The key that <paramref name="element"/> is located under.</param>
        /// <param name="element">The element to remove from <paramref name="key"/>. </param>
        /// <returns><c>true</c> if <paramref name="key"/> and <paramref name="element"/> existed, <c>false</c> if not.</returns>
        public bool Remove(TKey key, TElement element)
        {
            if (key == null)
                return nullGrouping.Remove(element);

            if (!groupings.ContainsKey(key))
                return false;

            if (groupings[key].Remove(element))
            {
                if (groupings[key].Count == 0)
                    groupings.Remove(key);

                return true;
            }

            return false;
        }

        /// <summary>
        /// Removes <paramref name="key"/> from the lookup.
        /// </summary>
        /// <param name="key">They to remove.</param>
        /// <returns><c>true</c> if <paramref name="key"/> existed.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="key"/> is <c>null</c>.</exception>
        public bool Remove(TKey key)
        {
            if (key == null)
            {
                bool removed = (nullGrouping.Count > 0);
                nullGrouping.Clear();
                return removed;
            }

            return groupings.Remove(key);
        }

        public void Clear()
        {
            if (nullGrouping != null)
                nullGrouping.Clear();

            groupings.Clear();
        }

        public bool TryGetValues(TKey key, out IEnumerable<TElement> values)
        {
            values = null;

            if (key == null)
            {
                if (nullGrouping.Count != 0)
                {
                    values = nullGrouping;
                    return true;
                }
                else
                    return false;
            }

            MutableLookupGrouping grouping;
            if (!groupings.TryGetValue(key, out grouping))
                return false;

            values = grouping;
            return true;
        }


        [TestMethod]
        public void TestEmptyListInEmptyListOut()
        {
            var uniqueGroupings = UniqueGroupings();
            Assert.AreEqual(0, uniqueGroupings.Count);
        }

        [TestMethod]
        public void TestTwoIdenticalGroupingsReducedToOne()
        {
            var uniqueGroupings = UniqueGroupings(Grouping(), Grouping());
            Assert.AreEqual(1, uniqueGroupings.Count);
        }

        [TestMethod]
        public void TestUniquifyOnIndicatorId()
        {
            var grouping = Grouping();
            grouping.IndicatorId = UniqueValue;
            var uniqueGroupings = UniqueGroupings(Grouping(), grouping);
            Assert.AreEqual(2, uniqueGroupings.Count);
        }

        [TestMethod]
        public void TestUniquifyOnSexId()
        {
            var grouping = Grouping();
            grouping.SexId = UniqueValue;
            var uniqueGroupings = UniqueGroupings(Grouping(), grouping);
            Assert.AreEqual(2, uniqueGroupings.Count);
        }

        [TestMethod]
        public void TestUniquifyOnAreaTypeId()
        {
            var grouping = Grouping();
            grouping.AreaTypeId = UniqueValue;
            var uniqueGroupings = UniqueGroupings(Grouping(), grouping);
            Assert.AreEqual(2, uniqueGroupings.Count);
        }

        [TestMethod]
        public void TestUniquifyOnComparatorId()
        {
            var grouping = Grouping();
            grouping.ComparatorId = UniqueValue;
            var uniqueGroupings = UniqueGroupings(Grouping(), grouping);
            Assert.AreEqual(2, uniqueGroupings.Count);
        }

        /// <summary>
        ///     Get the minimum for Value, LowerCI and UpperCI
        /// </summary>
        /// <returns>Minimum value</returns>
        double? GetMin(Grouping grouping, IEnumerable<string> areaCodes);

        /// <summary>
        ///     Get the maximum for Value, LowerCI and UpperCI
        /// </summary>
        /// <returns>Maximum value</returns>
        double? GetMax(Grouping grouping, IEnumerable<string> areaCodes);

        /// <summary>
        /// Gets all core data between the base line and data point time points of a grouping.
        /// </summary>
        /// <returns>List of CoreDataSet</returns>
        IList<CoreDataSet> GetTrendData(Grouping grouping, string areaCode);

        IDictionary<string, IList<CoreDataSet>> GetTrendDataForMultipleAreas(Grouping grouping, params string[] areaCodes);

        IList<CoreDataSet> GetTrendDataForSpecificCategory(Grouping grouping, string areaCode,
            int categoryTypeId, int categoryId);

        /// <summary>
        ///     Get the minimum for Value, LowerCI and UpperCI
        /// </summary>
        /// <returns>Minimum value</returns>
        public double? GetMin(Grouping grouping, IEnumerable<string> areaCodes)
        {
            return GetLimit(grouping, "min", areaCodes).Min();
        }

        [TestMethod]
        public void TestPolarityAssignedFromGrouping()
        {
            // Assign
            var polarity = PolarityIds.RagHighIsGood;
            List<Grouping> grouping = new List<Grouping>
            {
                new Grouping { IndicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth, PolarityId = polarity }
            };

            // Action
            var root = new GroupRootBuilder(ReaderFactory.GetGroupDataReader()).BuildGroupRoots(grouping).First();

            // Assert
            Assert.AreEqual(polarity, root.PolarityId);
        }

        [TestMethod]
        public void TestAgeIdAssignedFromGrouping()
        {
            // Assign
            var ageId = AgeIds.From4To5;
            var indicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth;

            List<Grouping> grouping = new List<Grouping>
            {
                new Grouping { AgeId = ageId, IndicatorId = indicatorId }
            };

            // Action
            var root = new GroupRootBuilder(ReaderFactory.GetGroupDataReader()).BuildGroupRoots(grouping).First();

            // Assert
            Assert.AreEqual(ageId, root.AgeId);
        }

        [TestMethod]
        public void TestSexIdAssignedFromGrouping()
        {
            // Assign
            List<Grouping> grouping = new List<Grouping>
            {
                new Grouping { IndicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth, SexId = SexIds.Male },
                new Grouping { IndicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth, SexId = SexIds.Female }
            };

            // Action
            var roots = new GroupRootBuilder(ReaderFactory.GetGroupDataReader()).BuildGroupRoots(grouping);

            // Assert
            Assert.AreEqual(SexIds.Male, roots[0].SexId);
            Assert.AreEqual(SexIds.Female, roots[1].SexId);
        }

        [TestMethod]
        public void TestTwoGroupings()
        {
            // Assign
            List<Grouping> grouping = new List<Grouping>
            {
                new Grouping { IndicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth, SexId = SexIds.Male },
                new Grouping { IndicatorId = IndicatorIds.DeprivationScoreIMD2015, SexId = SexIds.Persons }
            };

            // Action
            var roots = new GroupRootBuilder(ReaderFactory.GetGroupDataReader()).BuildGroupRoots(grouping);

            // Assert
            Assert.AreEqual(2, roots.Count);
        }

        [TestMethod]
        public void TestGroupingsAnnualAndQuarterlyGroupingsGiveTwoGroupRoots()
        {
            // Assign
            List<Grouping> grouping = new List<Grouping>
            {
                new Grouping
                {
                    IndicatorId = IndicatorIds.ChildrenInLowIncomeFamilies,
                    SexId = SexIds.Male,
                    BaselineYear = 2001,
                    BaselineQuarter = -1,
                    DataPointYear = 2001,
                    DataPointQuarter = -1
                },
                new Grouping
                {
                    IndicatorId = IndicatorIds.ChildrenInLowIncomeFamilies,
                    SexId = SexIds.Male,
                    BaselineYear = 2001,
                    BaselineQuarter = 1,
                    DataPointYear = 2001,
                    DataPointQuarter = 1
                }
            };

            // Action
            var roots = new GroupRootBuilder(ReaderFactory.GetGroupDataReader()).BuildGroupRoots(grouping);

            // Assert
            Assert.AreEqual(2, roots.Count);
        }

        [TestMethod]
        public void TestGroupingsAnnualAndMonthlyGroupingsGiveTwoGroupRoots()
        {
            // Assign
            List<Grouping> grouping = new List<Grouping>
            {
                new Grouping
                {
                    IndicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth,
                    SexId = SexIds.Male,
                    BaselineYear = 2009,
                    BaselineQuarter = -1,
                    DataPointYear = 2015,
                    DataPointQuarter = -1
                },
                new Grouping
                {
                    IndicatorId = IndicatorIds.HealthyLifeExpectancyAtBirth,
                    SexId = SexIds.Male,
                    BaselineYear = 2001,
                    BaselineQuarter = -1,
                    BaselineMonth = 1,
                    DataPointYear = 2001,
                    DataPointQuarter = -1,
                    DataPointMonth = 1
                }
            };

            // Action
            var roots = new GroupRootBuilder(ReaderFactory.GetGroupDataReader()).BuildGroupRoots(grouping);

            // Assert
            Assert.AreEqual(2, roots.Count);
        }


		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);
		}

        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 virtual Grouping GetGroupingByProfileIdAndGroupIdAndAreaTypeIdAndIndicatorIdAndSexIdAndAgeId(int profileId, int groupId,
            int areaTypeId, int indicatorId, int sexId, int ageId)
        {
            SetWhetherToUseCommonestPolarity(profileId);
            var groupIds = GetGroupIds(groupId, profileId);
            return GetGrouping(groupIds, areaTypeId, indicatorId, sexId, ageId);
        }

        public virtual Grouping GetGroupingByProfileIdAndAreaTypeIdAndIndicatorIdAndSexIdAndAgeId(int profileId, int areaTypeId,
            GroupingDifferentiator groupingDifferentiator)
        {
            SetWhetherToUseCommonestPolarity(profileId);
            var groupIds = groupIdProvider.GetGroupIds(profileId);
            return GetGrouping(groupIds, areaTypeId, groupingDifferentiator.IndicatorId, groupingDifferentiator.SexId, groupingDifferentiator.AgeId);
        }

        public virtual Grouping GetGroupingByProfileIdAndAreaTypeIdAndIndicatorIdAndSexIdAndAgeId(int profileId, int areaTypeId,
            int indicatorId, int sexId, int ageId)
        {
            SetWhetherToUseCommonestPolarity(profileId);
            var groupIds = groupIdProvider.GetGroupIds(profileId);
            return GetGrouping(groupIds, areaTypeId, indicatorId, sexId, ageId);
        }

        public virtual Grouping GetGroupingByGroupIdAndAreaTypeIdAndIndicatorIdAndSexIdAndAgeId(int groupId, int areaTypeId, int indicatorId, int sexId, int ageId)
        {
            useCommonestPolarity = false;
            return GetGrouping(new List<int> { groupId }, areaTypeId, indicatorId, sexId, ageId);
        }

        public virtual Grouping GetGroupingByProfileIdAndAreaTypeIdAndIndicatorIdAndSexId(int profileId, int areaTypeId, int indicatorId, int sexId)

        {
            SetWhetherToUseCommonestPolarity(profileId);
            var groupIds = groupIdProvider.GetGroupIds(profileId);
            return GetGroupingBySexId(groupIds, areaTypeId, indicatorId, sexId);
        }

        public virtual Grouping GetGroupingByProfileIdAndAreaTypeIdAndIndicatorIdAndAgeId(
            int profileId, int areaTypeId, int indicatorId, int ageId)
        {
            SetWhetherToUseCommonestPolarity(profileId);
            var groupIds = groupIdProvider.GetGroupIds(profileId);
            return GetGroupingByAgeId(groupIds, areaTypeId, indicatorId, ageId);
        }

        [TestMethod]
        public void TestOrderByYear()
        {
            var groupings = new List<Grouping>
            {
                GetGrouping(2014, 1, 1),
                GetGrouping(2011, 1, 1),
                GetGrouping(2013, 1, 1),
                GetGrouping(2012, 1, 1)
            };

            var sorted = new GroupingSorter(groupings).SortByDataPointTimePeriodMostRecentFirst();

            Assert.AreEqual(2014, sorted[0].DataPointYear);
            Assert.AreEqual(2013, sorted[1].DataPointYear);
            Assert.AreEqual(2012, sorted[2].DataPointYear);
            Assert.AreEqual(2011, sorted[3].DataPointYear);
        }

        [TestMethod]
        public void TestBaseLineOrderByYear()
        {
            var groupings = new List<Grouping>
            {
                GetBaseLineGrouping(2014, 1, 1),
                GetBaseLineGrouping(2011, 1, 1),
                GetBaseLineGrouping(2013, 1, 1),
                GetBaseLineGrouping(2012, 1, 1)
            };

            var sorted = new GroupingSorter(groupings).SortByBaseLineTimePeriodEarliestFirst();

            Assert.AreEqual(2011, sorted[0].BaselineYear);
            Assert.AreEqual(2012, sorted[1].BaselineYear);
            Assert.AreEqual(2013, sorted[2].BaselineYear);
            Assert.AreEqual(2014, sorted[3].BaselineYear);
        }

        [TestMethod]
        public void TestOrderByYearAndMonth()
        {
            var groupings = new List<Grouping>
            {
                GetGrouping(2014, 1, 1),
                GetGrouping(2014, 1, 2),
                GetGrouping(2013, 1, 2),
                GetGrouping(2013, 1, 1)
            };

            var sorted = new GroupingSorter(groupings).SortByDataPointTimePeriodMostRecentFirst();

            // Assert years 
            Assert.AreEqual(2014, sorted[0].DataPointYear);
            Assert.AreEqual(2014, sorted[1].DataPointYear);
            Assert.AreEqual(2013, sorted[2].DataPointYear);
            Assert.AreEqual(2013, sorted[3].DataPointYear);

            // Assert months 
            Assert.AreEqual(2, sorted[0].DataPointMonth);
            Assert.AreEqual(1, sorted[1].DataPointMonth);
            Assert.AreEqual(2, sorted[2].DataPointMonth);
            Assert.AreEqual(1, sorted[3].DataPointMonth);
        }

        [TestMethod]
        public void TestBaseLineOrderByYearAndMonth()
        {
            var groupings = new List<Grouping>
            {
                GetBaseLineGrouping(2014, 1, 1),
                GetBaseLineGrouping(2014, 1, 2),
                GetBaseLineGrouping(2013, 1, 2),
                GetBaseLineGrouping(2013, 1, 1)
            };

            var sorted = new GroupingSorter(groupings).SortByBaseLineTimePeriodEarliestFirst();

            // Assert years 
            Assert.AreEqual(2013, sorted[0].BaselineYear);
            Assert.AreEqual(2013, sorted[1].BaselineYear);
            Assert.AreEqual(2014, sorted[2].BaselineYear);
            Assert.AreEqual(2014, sorted[3].BaselineYear);

            // Assert months 
            Assert.AreEqual(1, sorted[0].BaselineMonth);
            Assert.AreEqual(2, sorted[1].BaselineMonth);
            Assert.AreEqual(1, sorted[2].BaselineMonth);
            Assert.AreEqual(2, sorted[3].BaselineMonth);
        }

        [TestMethod]
        public void TestOrderByYearAndQuarter()
        {
            var groupings = new List<Grouping>
            {
                GetGrouping(2014, 1, 1),
                GetGrouping(2014, 2, 1),
                GetGrouping(2013, 2, 1),
                GetGrouping(2013, 1, 1)
            };

            var sorted = new GroupingSorter(groupings).SortByDataPointTimePeriodMostRecentFirst();

            // Assert years 
            Assert.AreEqual(2014, sorted[0].DataPointYear);
            Assert.AreEqual(2014, sorted[1].DataPointYear);
            Assert.AreEqual(2013, sorted[2].DataPointYear);
            Assert.AreEqual(2013, sorted[3].DataPointYear);

            // Assert months 
            Assert.AreEqual(2, sorted[0].DataPointQuarter);
            Assert.AreEqual(1, sorted[1].DataPointQuarter);
            Assert.AreEqual(2, sorted[2].DataPointQuarter);
            Assert.AreEqual(1, sorted[3].DataPointQuarter);
        }

        [TestMethod]
        public void TestBaseLineOrderByYearAndQuarter()
        {
            var groupings = new List<Grouping>
            {
                GetBaseLineGrouping(2014, 1, 1),
                GetBaseLineGrouping(2014, 2, 1),
                GetBaseLineGrouping(2013, 2, 1),
                GetBaseLineGrouping(2013, 1, 1)
            };

            var sorted = new GroupingSorter(groupings).SortByBaseLineTimePeriodEarliestFirst();

            // Assert years 
            Assert.AreEqual(2013, sorted[0].BaselineYear);
            Assert.AreEqual(2013, sorted[1].BaselineYear);
            Assert.AreEqual(2014, sorted[2].BaselineYear);
            Assert.AreEqual(2014, sorted[3].BaselineYear);

            // Assert months 
            Assert.AreEqual(1, sorted[0].BaselineQuarter);
            Assert.AreEqual(2, sorted[1].BaselineQuarter);
            Assert.AreEqual(1, sorted[2].BaselineQuarter);
            Assert.AreEqual(2, sorted[3].BaselineQuarter);
        }

Uno.Grouping<TKey, TValues> : IGrouping

Constructors :

public Grouping(TKey key = , IEnumerable<TValues> values = )

Methods :

public TKey get_Key()
public IEnumerable<TValues> get_Values()
public IEnumerator<TValues> GetEnumerator()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()