Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class SingleValueEncapsulator<T>
- {
- private readonly T _value;
- public SingleValueEncapsulator(T value)
- {
- _value = value;
- }
- protected T Value
- {
- get { return _value; }
- }
- protected bool Equals(SingleValueEncapsulator<T> other)
- {
- return EqualityComparer<T>.Default.Equals(_value, other._value);
- }
- public override bool Equals(object candidate)
- {
- if (ReferenceEquals(null, candidate))
- {
- return false;
- }
- if (ReferenceEquals(this, candidate))
- {
- return true;
- }
- if (candidate.GetType() != this.GetType())
- {
- return false;
- }
- return Equals((SingleValueEncapsulator<T>) candidate);
- }
- public override int GetHashCode()
- {
- return EqualityComparer<T>.Default.GetHashCode(_value);
- }
- }
- class FileUid
- {
- // ...
- }
- class FileUidOperation : SingleValueEncapsulator<FileUid>
- {
- public FileUidOperation() : base(new FileUid())
- {
- }
- public FileUid Target => Value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement