LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
NamedEntity.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
3
5
6/// <summary>
7/// Base class for model entities that have a name.
8///
9/// This class does not define an identifier because some entities in the
10/// source UML model, such as the generic Warehouse class, only define a name.
11/// </summary>
12[Serializable]
13[XmlType(TypeName = "namedEntity")]
14public abstract class NamedEntity : ModelObject
15{
16 private string _name = string.Empty;
17
18 /// <summary>
19 /// Initializes a new instance of the <see cref="NamedEntity"/> class.
20 ///
21 /// Derived serializable classes must expose their own public
22 /// parameterless constructor.
23 /// </summary>
24 protected NamedEntity()
25 {
26 }
27
28 /// <summary>
29 /// Gets or sets the entity name.
30 /// </summary>
31 [XmlAttribute("name")]
32 public string Name
33 {
34 get => _name;
35 set => SetProperty(
36 ref _name,
37 value ?? string.Empty); // Ensure the name is never null
38 }
39
40 /// <summary>
41 /// Returns the entity name.
42 /// </summary>
43 public override string ToString()
44 {
45 return Name;
46 }
47}
Base class for model objects that notify listeners when one of their properties changes.
string Name
Gets or sets the entity name.
NamedEntity()
Initializes a new instance of the NamedEntity class.
override string ToString()
Returns the entity name.