// ************************************************* // Project: RENAPI // File name: Rec.cs // Developer: Nicholas Greiner // Creation Date: 03/03/2014 2:12 PM // Last Changed: 05/27/2014 3:11 PM // ************************************************* using System; using System.Web.Script.Serialization; using MongoDB.Bson.Serialization.Attributes; namespace bn.pds.ren.RENAPI.objects.ren { [BsonIgnoreExtraElements] public sealed class Rec : IEquatable { public Rec() { } public Rec(long ean, long score) { Ean = ean; Score = score; } [BsonId] public long Ean { get; set; } public long Score { get; set; } //public long Id { get { return Ean; } } public long PrimaryKey { get { return Ean; } } public override string ToString() { return new JavaScriptSerializer().Serialize(this); } public bool Equals(Rec other) { //Check whether the compared object is null. if (Object.ReferenceEquals(other, null)) return false; //Check whether the compared object references the same data. if (Object.ReferenceEquals(this, other)) return true; //Check whether the products' properties are equal. return Ean.Equals(other.Ean); } // If Equals() returns true for a pair of objects // then GetHashCode() must return the same value for these objects. public override int GetHashCode() { return Ean.GetHashCode(); } } }