Advertisement
Lusien_Lashans

toze

Feb 27th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6.  
  7. namespace hashes
  8. {
  9.     public class Document
  10.     {
  11.         private readonly Encoding encoding;
  12.         private readonly byte[] content;
  13.         public string Title { get; }
  14.         public string Content => encoding.GetString(content);
  15.  
  16.  
  17.         public Document(string title, Encoding encoding, byte[] content)
  18.         {
  19.             Title = title;
  20.             this.encoding = encoding;
  21.             this.content = content;
  22.         }
  23.  
  24.         protected bool Equals(Document other)
  25.         {
  26.             return string.Equals(Title, other.Title)
  27.                 && Content.Equals(other.Content);
  28.         }
  29.  
  30.         public override bool Equals(object obj)
  31.         {
  32.             if (ReferenceEquals(null, obj)) return false;
  33.             if (ReferenceEquals(this, obj)) return true;
  34.             if (obj.GetType() != GetType()) return false;
  35.             return Equals((Document) obj);
  36.         }
  37.  
  38.         public override int GetHashCode()
  39.         {
  40.             unchecked
  41.             {
  42.                 return Title.GetHashCode() * 397 ^ Content.GetHashCode();
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement