Exemple #1
0
		/// <summary>
		/// Add a single entry.
		/// </summary>
		public void AddEntry(string cvsName, User user)
		{
			m_map[cvsName] = user;
		}
Exemple #2
0
		/// <summary>
		/// Parse a user file.
		/// </summary>
		/// <exception cref="IOException">if an error occurs reading the file</exception>
		/// <remarks>This overload exists primarily for the user by testcode, where we're reading a test file
		/// from resources.</remarks>
		public void ParseUserFile(TextReader reader, string filename)
		{
			try
			{
				int lineNumber = 0;
				string line;

				while ((line = reader.ReadLine()) != null)
				{
					lineNumber++;
					line = line.Trim();
					if (line.Length == 0)
						continue;

					var parts = line.Split('\t');
					if (parts.Length != 3)
						throw new IOException(String.Format("{0}({1}): Invalid format in user file", filename, lineNumber));

					var cvsName = parts[0].Trim();
					if (m_map.ContainsKey(cvsName))
						throw new IOException(String.Format("{0}({1}): User {2} appears twice", filename, lineNumber, cvsName));

					var user = new User(parts[1].Trim(), parts[2].Trim());
					m_map[cvsName] = user;
				}
			}
			catch (UnauthorizedAccessException uae)
			{
				throw new IOException(uae.Message, uae);
			}
			catch (System.Security.SecurityException se)
			{
				throw new IOException(se.Message, se);
			}
		}
Exemple #3
0
		private string WriteUser(User user)
		{
			return String.Format("{0} <{1}>", user.Name, user.Email);
		}