Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ProjectReference.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.Diagnostics;
5 using SiliconStudio.Core;
6 using SiliconStudio.Core.IO;
7 
8 namespace SiliconStudio.Assets
9 {
10  /// <summary>
11  /// A reference to a Visual Studio project that is part of a <see cref="Package"/>
12  /// </summary>
13  [DataContract("ProjectReference")]
14  [DebuggerDisplay("Id: {Id}, Location: {Location}")]
15  public sealed class ProjectReference : IEquatable<ProjectReference>
16  {
17  /// <summary>
18  /// Initializes a new instance of the <see cref="ProjectReference"/> class.
19  /// </summary>
21  {
22  }
23 
24  /// <summary>
25  /// Initializes a new instance of the <see cref="ProjectReference"/> class.
26  /// </summary>
27  /// <param name="id">The identifier.</param>
28  /// <param name="location">The location.</param>
29  /// <param name="type">The type.</param>
30  public ProjectReference(Guid id, UFile location, ProjectType type)
31  {
32  Id = id;
33  Location = location;
34  Type = type;
35  }
36 
37  /// <summary>
38  /// Gets or sets the unique identifier of the VS project.
39  /// </summary>
40  /// <value>The identifier.</value>
41  [DataMember(10)]
42  public Guid Id { get; set; }
43 
44  /// <summary>
45  /// Gets or sets the location of the file on the disk.
46  /// </summary>
47  /// <value>The location.</value>
48  [DataMember(20)]
49  public UFile Location { get; set; }
50 
51  /// <summary>
52  /// Gets or sets the type of project.
53  /// </summary>
54  /// <value>The type.</value>
55  [DataMember(30)]
56  public ProjectType Type { get; set; }
57 
58  public bool Equals(ProjectReference other)
59  {
60  if (ReferenceEquals(null, other)) return false;
61  if (ReferenceEquals(this, other)) return true;
62  return Id.Equals(other.Id) && Equals(Location, other.Location) && Type == other.Type;
63  }
64 
65  public override bool Equals(object obj)
66  {
67  if (ReferenceEquals(null, obj)) return false;
68  if (ReferenceEquals(this, obj)) return true;
69  return obj is ProjectReference && Equals((ProjectReference)obj);
70  }
71 
72  public override int GetHashCode()
73  {
74  unchecked
75  {
76  var hashCode = Id.GetHashCode();
77  hashCode = (hashCode*397) ^ (Location != null ? Location.GetHashCode() : 0);
78  hashCode = (hashCode*397) ^ (int)Type;
79  return hashCode;
80  }
81  }
82 
83  public static bool operator ==(ProjectReference left, ProjectReference right)
84  {
85  return Equals(left, right);
86  }
87 
88  public static bool operator !=(ProjectReference left, ProjectReference right)
89  {
90  return !Equals(left, right);
91  }
92  }
93 }
ProjectReference(Guid id, UFile location, ProjectType type)
Initializes a new instance of the ProjectReference class.
ProjectType
Type of the project.
Definition: ProjectType.cs:11
ProjectReference()
Initializes a new instance of the ProjectReference class.
UFile Location
Gets or sets the location of the file on the disk.
A reference to a Visual Studio project that is part of a Package
bool Equals(ProjectReference other)
Defines a normalized file path. See UPath for details. This class cannot be inherited.
Definition: UFile.cs:13
override bool Equals(object obj)