<commit_before>﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

namespace Project.GtfsNet.Entities
{
	/// <remarks>
	/// https://github.com/OsmSharp/GTFS/blob/2b8f3201e65ab5dd31cdacd82b4b05d34c288204/GTFS/Entities/Agency.cs
	/// </remarks>
	public class Agency : IEntity, IEqualityComparer<Agency>
	{
		public string Id { get; set; }

		[Required]
		public string Name { get; set; }

		[Required]
		public string Url { get; set; }

		[Required]
		public string Timezone { get; set; }

		public string Language { get; set; }

		public string Phone { get; set; }

		public string FareUrl { get; set; }

		/// <summary>
		/// Credit <see cref="https://github.com/OsmSharp/GTFS/blob/2b8f3201e65ab5dd31cdacd82b4b05d34c288204/GTFS/Entities/Agency.cs"/>
		/// </summary>
		public override string ToString()
		{
			return string.Format("[{0}] {1}", Id, Name);
		}

		public override bool Equals(object obj)
		{
			Agency agency = obj as Agency;
			return agency.Id == Id &&
				   agency.Name == Name &&
				   agency.Url == Url &&
				   agency.Timezone == Timezone &&
				   agency.Language == Language &&
				   agency.Phone == Phone &&
				   agency.FareUrl == FareUrl;
		}

		public bool Equals(Agency x, Agency y)
		{
			return x.Equals(y);
		}

		public int GetHashCode(Agency agency)
		{
			return agency.Id.GetHashCode() +
				   agency.Name.GetHashCode() +
				   agency.Url.GetHashCode() +
				   agency.Timezone.GetHashCode() +
				   agency.Language.GetHashCode() +
				   agency.Phone.GetHashCode() +
				   agency.FareUrl.GetHashCode();
		}
	}
}<commit_msg>Equals & GetHashCode are calculated and retrieved via reflection (,which will be used for other classes implementing IEntity later)<commit_after>﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;

namespace Project.GtfsNet.Entities
{
	/// <remarks>
	/// https://github.com/OsmSharp/GTFS/blob/2b8f3201e65ab5dd31cdacd82b4b05d34c288204/GTFS/Entities/Agency.cs
	/// </remarks>
	public class Agency : IEntity, IEqualityComparer<Agency>
	{
		public string Id { get; set; }

		[Required]
		public string Name { get; set; }

		[Required]
		public string Url { get; set; }

		[Required]
		public string Timezone { get; set; }

		public string Language { get; set; }

		public string Phone { get; set; }

		public string FareUrl { get; set; }

		/// <summary>
		/// Credit <see cref="https://github.com/OsmSharp/GTFS/blob/2b8f3201e65ab5dd31cdacd82b4b05d34c288204/GTFS/Entities/Agency.cs"/>
		/// </summary>
		public override string ToString()
		{
			return string.Format("[{0}] {1}", Id, Name);
		}

		public override bool Equals(object obj)
		{
			Agency agency = obj as Agency;
			if (agency == null) return false;

			return AreEqual(agency, this);
		}

		public bool Equals(Agency x, Agency y)
		{
			return x.Equals(y);
		}

		public int GetHashCode(Agency agency)
		{
			return ComputeHashCode(agency);
		}

		protected int ComputeHashCode<T>(T obj)
		{
			return obj.GetType().GetProperties().Sum(property => property.GetHashCode());
		}

		protected bool AreEqual<T>(T obj1, T obj2)
		{
			// http://stackoverflow.com/a/2502468/4035
			foreach (PropertyInfo property in obj1.GetType().GetProperties())
			{
				object value1 = property.GetValue(obj1, null);
				object value2 = property.GetValue(obj2, null);

				if (!value1.Equals(value2))
					return false;
			}

			return true;
		}
	}
}
{'fraction_non_alphanumeric': 0.13128976286871025, 'fraction_numerical': 0.03470213996529786, 'mean_word_length': 3.291563275434243, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 18, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5825446', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1182, 'n_words': 263}