-
Notifications
You must be signed in to change notification settings - Fork 22
/
ProductType.cs
52 lines (44 loc) · 1.38 KB
/
ProductType.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
// Copyright (c) 2023, Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0
using Moryx.AbstractionLayer.Identity;
namespace Moryx.AbstractionLayer.Products
{
/// <summary>
/// Base class for all products
/// </summary>
public abstract class ProductType : IProductType
{
/// <inheritdoc />
public long Id { get; set; }
/// <inheritdoc />
public string Name { get; set; }
/// <inheritdoc />
public ProductState State { get; set; }
/// <inheritdoc />
public IIdentity Identity { get; set; }
/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="System.String" /> that represents this instance.
/// </returns>
public override string ToString()
{
return Identity?.ToString();
}
/// <summary>
/// Create instance of this type
/// </summary>
public ProductInstance CreateInstance()
{
var instance = Instantiate();
instance.Type = this;
return instance;
}
/// <summary>
/// Instantiate this product
/// </summary>
/// <returns>New instance</returns>
protected abstract ProductInstance Instantiate();
}
}