Skip to content

Commit

Permalink
Use additional operations that are recommended for structures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ramondeklein committed Feb 4, 2017
1 parent a7b8945 commit b8198b8
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions NWebDav.Server/Stores/IStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ public StoreItemResult(DavStatusCode result, IStoreItem item = null)
Result = result;
Item = item;
}

public static bool operator!=(StoreItemResult left, StoreItemResult right)
{
return !(left == right);
}

public static bool operator==(StoreItemResult left, StoreItemResult right)
{
return left.Result == right.Result && (left.Item == null && right.Item == null || left.Item != null && left.Item.Equals(right.Item));
}

public override bool Equals(object obj)
{
if (!(obj is StoreItemResult))
return false;
return this == (StoreItemResult)obj;
}

public override int GetHashCode() => Result.GetHashCode() ^ (Item?.GetHashCode() ?? 0);
}

public struct StoreCollectionResult
Expand All @@ -31,6 +50,25 @@ public StoreCollectionResult(DavStatusCode result, IStoreCollection collection =
Result = result;
Collection = collection;
}

public static bool operator !=(StoreCollectionResult left, StoreCollectionResult right)
{
return !(left == right);
}

public static bool operator ==(StoreCollectionResult left, StoreCollectionResult right)
{
return left.Result == right.Result && (left.Collection == null && right.Collection == null || left.Collection != null && left.Collection.Equals(right.Collection));
}

public override bool Equals(object obj)
{
if (!(obj is StoreCollectionResult))
return false;
return this == (StoreCollectionResult)obj;
}

public override int GetHashCode() => Result.GetHashCode() ^ (Collection?.GetHashCode() ?? 0);
}

public interface IStore
Expand Down

0 comments on commit b8198b8

Please sign in to comment.