NOS.Registration.PageFormatter.AddEntry C# (CSharp) Method

AddEntry() public method

public AddEntry ( string content, string entry, User user, IPluginConfiguration configuration ) : string
content string
entry string
user User
configuration IPluginConfiguration
return string
		public string AddEntry(string content, string entry, User user, IPluginConfiguration configuration)
		{
			var entryMatcher = NewRegex(configuration.EntryPattern);
			var listStartMatcher = NewRegex(configuration.ListStartPattern);
			var listEndMatcher = NewRegex(configuration.ListEndPattern);
			var waitingListEndMatcher = NewRegex(configuration.WaitingListEndPattern);

			int listStart = AssertMatchesOnce(content, listStartMatcher, "list start");
			int listEnd = AssertMatchesOnce(content, listEndMatcher, "list end");
			int waitingListEnd = AssertMatchesOnce(content, waitingListEndMatcher, "waiting list end");
			if (listEnd == -1 || listEnd == -1 || waitingListEnd == -1)
			{
				throw new InvalidOperationException(
					"The list and/or waiting list regular expressions did not match once. See previous errors.");
			}

			if (listEnd < listStart)
			{
				_logger.Error(String.Format("The list end position ({0}) is before the list start position ({1})",
				                            listEnd,
				                            listStart),
				              "SYSTEM");
				throw new InvalidOperationException("The list start and end positions are not sanitized. See previous error.");
			}

			int numberOfAttendees = CountNumberOfEntries(content.Substring(listStart, listEnd - listStart), entryMatcher);

			int addAtIndex = _opinionEvaluator.Evaluate(new EvaluationContext
				                           {
				                           	NumberOfAttendees = numberOfAttendees,
				                           	ListEnd = listEnd,
				                           	WaitingListEnd = waitingListEnd,
				                           	Configuration = configuration,
				                           	User = user,
				                           	Logger = _logger
				                           });

			return content.Insert(addAtIndex, entry);
		}
		#endregion