Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ObservableViewModelIdentifier.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.Collections.Generic;
5 using System.Linq;
6 
7 namespace SiliconStudio.Presentation.Quantum
8 {
9  public struct ObservableViewModelIdentifier : IEquatable<ObservableViewModelIdentifier>
10  {
11  private readonly HashSet<Guid> guids;
12 
13 
14  internal ObservableViewModelIdentifier(Guid guid)
15  {
16  guids = new HashSet<Guid> { guid };
17  }
18 
20  {
21  this.guids = new HashSet<Guid>();
22  foreach (var guid in guids)
23  this.guids.Add(guid);
24  }
25 
26  public bool IsCombined { get { return guids.Count > 1; } }
27 
28  public bool Match(ObservableViewModelIdentifier identifier)
29  {
30  return guids.Count == identifier.guids.Count && guids.All(guid => identifier.guids.Contains(guid));
31  }
32 
33  public bool Equals(ObservableViewModelIdentifier identifier)
34  {
35  return Match(identifier);
36  }
37 
38  public override bool Equals(object obj)
39  {
41  }
42 
43  public override int GetHashCode()
44  {
45  unchecked
46  {
47  return guids.Aggregate(0, (current, guid) => (guid.GetHashCode() * 397) ^ current);
48  }
49  }
50  }
51 }