LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
Item.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Represents a finished or semi-finished item handled by the supply chain.
9///
10/// Corresponds to the UML class "Article".
11/// </summary>
12[Serializable]
13[XmlType(TypeName = "item")]
14public sealed class Item : IdentifiedEntity
15{
16 private int _billOfMaterialsLevel;
17
18 /// <summary>
19 /// Initializes a new instance of the <see cref="Item"/> class.
20 ///
21 /// This public parameterless constructor is required
22 /// by <see cref="XmlSerializer"/>.
23 /// </summary>
24 public Item()
25 {
26 }
27
28 /// <summary>
29 /// Initializes an item with its identifier, name
30 /// and bill-of-materials level.
31 /// </summary>
32 /// <param name="id">
33 /// Numerical identifier corresponding to i in the source model.
34 /// </param>
35 /// <param name="name">
36 /// Item name.
37 /// </param>
38 /// <param name="billOfMaterialsLevel">
39 /// Bill-of-materials level corresponding to Γᵢ.
40 /// </param>
41 public Item(
42 int id,
43 string name,
44 int billOfMaterialsLevel)
45 {
46 // Initialize all item properties
47 Id = id;
48 Name = name;
49 BillOfMaterialsLevel = billOfMaterialsLevel; // Validation occurs in the setter
50 }
51
52 /// <summary>
53 /// Gets or sets the item's bill-of-materials level.
54 ///
55 /// Corresponds to Γᵢ in the source model.
56 /// Level zero generally represents a finished product.
57 /// Higher values represent lower levels in the bill of materials.
58 /// </summary>
59 [XmlAttribute("billOfMaterialsLevel")]
61 {
62 get => _billOfMaterialsLevel;
63 set
64 {
65 // Validate that the level is non-negative
66 if (value < 0)
67 {
68 throw new ArgumentOutOfRangeException(
69 nameof(value),
70 value,
71 "The bill-of-materials level cannot be negative.");
72 }
73
74 // Update the backing field and notify property change if value differs
75 SetProperty(
76 ref _billOfMaterialsLevel,
77 value);
78 }
79 }
80}
int Id
Gets or sets the numerical identifier of the entity.
IdentifiedEntity()
Initializes a new instance of the IdentifiedEntity class.
string Name
Gets or sets the entity name.
Item()
Initializes a new instance of the Item class.
Definition Item.cs:24
int BillOfMaterialsLevel
Gets or sets the item's bill-of-materials level.
Definition Item.cs:61
Item(int id, string name, int billOfMaterialsLevel)
Initializes an item with its identifier, name and bill-of-materials level.
Definition Item.cs:41