forked from kyordhel/GPSRCmdGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpecificLocation.cs
138 lines (118 loc) · 4.35 KB
/
SpecificLocation.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace GPSRCmdGen
{
/// <summary>
/// Represents a place within a room on which an object can lie
/// </summary>
[Serializable, XmlRoot("location")]
public class SpecificLocation : Location, IEquatable<SpecificLocation>
{
#region Variables
/// <summary>
/// Stores the room to which the placement belongs
/// </summary>
private Room room;
/// <summary>
///Indicates whether the location is suitable for placing a person.
/// </summary>
private bool isBeacon;
/// <summary>
/// Indicates whether the location is suitable for placing objects.
/// </summary>
private bool isPlacement;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.Placement"/> class.
/// </summary>
/// <remarks>Intended for serialization purposes only</remarks>
public SpecificLocation() : base() { }
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.Placement"/> class.
/// </summary>
/// <param name="name">The name of the location.</param>
/// <param name="placement">Indicates whether the location is
/// suitable for placing objects.</param>
/// <param name="beacon">Indicates whether the location is
/// suitable for placing objects.</param>
public SpecificLocation(string name, bool placement, bool beacon) : base(name, placement, beacon) { }
#endregion
#region Properties
/// <summary>
/// Gets a value indicating whether the location is suitable for placing a person.
/// </summary>
[XmlAttribute("isBeacon"), DefaultValue(false)]
public override bool IsBeacon
{
get { return this.isBeacon; }
set { this.isBeacon = value; }
}
/// <summary>
/// Gets a value indicating whether the location is suitable for placing objects.
/// </summary>
[XmlAttribute("isPlacement"), DefaultValue(false)]
public override bool IsPlacement
{
get { return this.isPlacement; }
set { this.isPlacement = value; }
}
/// <summary>
/// Gets or sets the room to which the placement belongs
/// </summary>
[XmlIgnore]
public Room Room
{
get { return this.room; }
set
{
if (this.room == value)
return;
this.room = value;
if (value != null)
value.AddLocation(this);
}
}
/// <summary>
/// Determines whether the specified <see cref="GPSRCmdGen.SpecificLocation"/> is equal to the current <see cref="GPSRCmdGen.SpecificLocation"/> by comparing their names.
/// </summary>
/// <param name="other">The <see cref="GPSRCmdGen.SpecificLocation"/> to compare with the current <see cref="GPSRCmdGen.SpecificLocation"/>.</param>
/// <returns><c>true</c> if the specified <see cref="GPSRCmdGen.SpecificLocation"/> is equal to the current
/// <see cref="GPSRCmdGen.Location"/>; otherwise, <c>false</c>.</returns>
public bool Equals(SpecificLocation other)
{
return String.Compare(this.Name, other.Name, true) == 0;
}
public override int GetHashCode()
{
return this.Name.GetHashCode();
}
/// <summary>
/// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="GPSRCmdGen.Location"/> at object level.
/// </summary>
/// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="GPSRCmdGen.Location"/>.</param>
/// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current
/// <see cref="GPSRCmdGen.Location"/>; otherwise, <c>false</c>.</returns>
public override bool Equals(object obj)
{
return base.Equals(obj);
}
/// <summary>
/// Creates a new instance of SpecificLocation with the given name and the properties
/// IsBeacon=true, IsPlacement=false
/// </summary>
/// <param name="name">The name of the beacon location</param>
/// <returns>A Specific Location</returns>
public static SpecificLocation Beacon(string name) { return new SpecificLocation(name, false, true); }
/// <summary>
/// Creates a new instance of SpecificLocation with the given name and the properties
/// IsBeacon=false, IsPlacement=true
/// </summary>
/// <param name="name">The name of the placement location</param>
/// <returns>A Specific Location</returns>
public static SpecificLocation Placement(string name) { return new SpecificLocation(name, true, false); }
#endregion
}
}