forked from kyordhel/GPSRCmdGen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PersonName.cs
93 lines (75 loc) · 2.26 KB
/
PersonName.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
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace GPSRCmdGen
{
/// <summary>
/// Represents a human gender
/// </summary>
public enum Gender{Female, Male}
/// <summary>
/// Represents a person name according to the RoboCup@Home Rulebook 2015
/// </summary>
[Serializable, XmlRoot("name")]
public class PersonName : INameable
{
#region Variables
/// <summary>
/// Stores a person's name.
/// </summary>
private string name;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.Name"/> class.
/// </summary>
/// <remarks>Intended for serialization purposes</remarks>
public PersonName () : this(String.Empty, Gender.Female){}
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.Name"/> class.
/// </summary>
/// <param name="value">The person's name</param>
public PersonName (string value) : this(value, Gender.Female){}
/// <summary>
/// Initializes a new instance of the <see cref="GPSRCmdGen.Name"/> class.
/// </summary>
/// <param name="value">The person's name</param>
/// <param name="gender">The person's gender</param>
public PersonName (string value, Gender gender){ this.name = value; this.Gender = gender;}
#endregion
#region Properties
/// <summary>
/// Gets the person's name this instance represents.
/// </summary>
[XmlText]
public string Name
{
get{ return this.name; }
set{ this.name = value; }
}
/// <summary>
/// Gets the gender of the stored name.
/// </summary>
[XmlAttribute("gender"), DefaultValue(Gender.Female)]
public Gender Gender{ get; set; }
#endregion
#region Methods
/// <summary>
/// Returns a <see cref="System.String"/> that represents the current <see cref="GPSRCmdGen.Name"/>.
/// </summary>
/// <returns>A <see cref="System.String"/> that represents the current <see cref="GPSRCmdGen.Name"/>.</returns>
public override string ToString ()
{
return this.Name;
}
/// <summary>
/// Implicitly converts a string to a female person's name
/// </summary>
/// <param name="s">String to cast/param>
public static implicit operator PersonName(string s){
return new PersonName (s);
}
#endregion
}
}