public int CountLengthForGroupUnit()

in FixAntenna/NetCore/Validation/Utils/FixUtil.cs [1107:1182]


		public int CountLengthForGroupUnit(Message.FixMessage message, int indexOfGroupTags, int startGroupTag,
			TagValue lengthOfGroupTag, ISet<int> stackOfGroupsTag, string messageType, int rootGroupStartTag)
		{
			IList<int> theFirstTags = new List<int>();
			var lengthOfGroup = 0;
			var msgSize = message.Length;
			if (indexOfGroupTags == -1)
			{
				theFirstTags.Add(lengthOfGroupTag.TagId);
				theFirstTags.Add(rootGroupStartTag);

				for (var indexOfFiled = 0; indexOfFiled < msgSize; indexOfFiled++)
				{
					var fixField = message[indexOfFiled];
					var tag = fixField.TagId;
					if (theFirstTags.Contains(tag))
					{
						// checks if the parent root tag.
						if (rootGroupStartTag == tag)
						{
							// checks if index less than size of message
							if (indexOfFiled + 1 < msgSize)
							{
								// checks if next tag from the group
								if (stackOfGroupsTag.Contains(message[indexOfFiled + 1].TagId))
								{
									lengthOfGroup = indexOfFiled + 1;
									continue;
								}

								// checks the last but one tag from the group.
								if (indexOfFiled + 2 == msgSize)
								{
									lengthOfGroup = indexOfFiled + 1;
									continue;
								}
							}
						}

						return lengthOfGroup;
					}

					if (stackOfGroupsTag.Contains(tag))
					{
						lengthOfGroup = indexOfFiled + 1;
						// if count of groups higer than size of message.
						if (indexOfFiled == msgSize - 1)
						{
							return CountLengthForOneGroupUnit(message, indexOfGroupTags, startGroupTag,
								lengthOfGroupTag, stackOfGroupsTag, messageType, rootGroupStartTag);
						}
					}
					else
					{
						var grFieldMap = GetGroupTagsWithInternalGroups(messageType, fixField.TagId, message);
						if (grFieldMap != null && grFieldMap.Count > 0)
						{
							return lengthOfGroup;
						}
					}
				}
			}
			else
			{
				var lengthOfPart = msgSize - (indexOfGroupTags + 1);
				if (lengthOfPart > 0)
				{
					var partOfMessageWithGroup = new Message.FixMessage();
					CopyFixElements(message, indexOfGroupTags + 1, partOfMessageWithGroup, lengthOfPart);
					lengthOfGroup = CountLengthForGroupUnit(partOfMessageWithGroup, -1, startGroupTag, lengthOfGroupTag,
						stackOfGroupsTag, messageType, rootGroupStartTag);
				}
			}

			return lengthOfGroup;
		}