Class VirtualItem<T>
Represents a virtual item. A virtual item is an object used to manage item data within the virtual storage. It holds item data based on the user-defined type T, facilitating the management and manipulation of various types of content.
Virtual items ensure that the actual data is distinctly present. If the user-defined type T implements the IVirtualDeepCloneable<T> interface, a deep clone of the item data is created, ensuring separate instances. If this interface is not implemented, shallow copies may result in multiple virtual items referencing the same instance of the item data.
Inherited Members
Namespace: AkiraNetwork.VirtualStorageLibrary
Assembly: VirtualStorageLibrary.dll
Syntax
public class VirtualItem<T> : VirtualItem, IVirtualDeepCloneable<VirtualNode>, IDisposable
Type Parameters
Name | Description |
---|---|
T | The user-defined type that can be freely specified by the user of this library. |
Constructors
VirtualItem()
Initializes a new instance of the VirtualItem<T> class. The node name is automatically generated by the GenerateNodeName(string) method.
Declaration
public VirtualItem()
VirtualItem(VirtualNodeName)
Initializes a new instance of the VirtualItem<T> class.
Declaration
public VirtualItem(VirtualNodeName name)
Parameters
Type | Name | Description |
---|---|---|
VirtualNodeName | name | The name of the item. |
VirtualItem(VirtualNodeName, T?)
Initializes a new instance of the VirtualItem<T> class.
Declaration
public VirtualItem(VirtualNodeName name, T? itemData)
Parameters
Type | Name | Description |
---|---|---|
VirtualNodeName | name | The name of the item. |
T | itemData | The data associated with this item. It is user-defined and can hold any type of data. |
VirtualItem(VirtualNodeName, T?, DateTime)
Initializes a new instance of the VirtualItem<T> class.
Declaration
public VirtualItem(VirtualNodeName name, T? itemData, DateTime createdDate)
Parameters
Type | Name | Description |
---|---|---|
VirtualNodeName | name | The name of the item. |
T | itemData | The data associated with this item. It is user-defined and can hold any type of data. |
DateTime | createdDate | The creation date of the item. |
VirtualItem(VirtualNodeName, T?, DateTime, DateTime)
Initializes a new instance of the VirtualItem<T> class.
Declaration
public VirtualItem(VirtualNodeName name, T? itemData, DateTime createdDate, DateTime updatedDate)
Parameters
Type | Name | Description |
---|---|---|
VirtualNodeName | name | The name of the item. |
T | itemData | The data associated with this item. It is user-defined and can hold any type of data. |
DateTime | createdDate | The creation date of the item. |
DateTime | updatedDate | The last update date of the item. |
Properties
ItemData
Gets or sets the data associated with this item. This value can be null.
Declaration
public T? ItemData { get; set; }
Property Value
Type | Description |
---|---|
T |
NodeType
Gets the type of the node.
Declaration
public override VirtualNodeType NodeType { get; }
Property Value
Type | Description |
---|---|
VirtualNodeType |
Overrides
Methods
DeepClone(bool)
Creates a deep clone of this item.
Declaration
public override VirtualNode DeepClone(bool recursive = false)
Parameters
Type | Name | Description |
---|---|---|
bool | recursive | If true, perform a deep clone recursively. |
Returns
Type | Description |
---|---|
VirtualNode | A deep clone of the current item as a VirtualNode. |
Overrides
Dispose()
Releases the resources used by the VirtualItem<T>.
Declaration
public void Dispose()
Dispose(bool)
Releases the unmanaged resources used by the VirtualItem<T> and optionally releases the managed resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing | true to release both managed and unmanaged resources; false to release only unmanaged resources. |
~VirtualItem()
Finalizer for the VirtualItem<T> class.
Declaration
protected ~VirtualItem()
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents the current object. |
Overrides
Update(VirtualNode)
Updates the current item with the specified node's data.
Declaration
public override void Update(VirtualNode node)
Parameters
Type | Name | Description |
---|---|---|
VirtualNode | node | The node containing the data to update. |
Overrides
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown if the specified node is not of the same type as the current item. |
Operators
implicit operator VirtualItem<T>((VirtualNodeName nodeName, T? itemData))
Converts a tuple (nodeName, itemData) to a VirtualItem<T>.
Declaration
public static implicit operator VirtualItem<T>((VirtualNodeName nodeName, T? itemData) tuple)
Parameters
Type | Name | Description |
---|---|---|
(VirtualNodeName nodeName, T itemData) | tuple | A tuple containing the node name and item data. |
Returns
Type | Description |
---|---|
VirtualItem<T> | A VirtualItem<T> initialized with the specified values. |
implicit operator VirtualItem<T>(T?)
Implicitly converts the specified data of type T to a VirtualItem<T>. The node name is automatically generated by the GenerateNodeName(string) method.
Declaration
public static implicit operator VirtualItem<T>(T? itemData)
Parameters
Type | Name | Description |
---|---|---|
T | itemData | The data associated with this item. It is user-defined and can hold any type of data. |
Returns
Type | Description |
---|---|
VirtualItem<T> | A VirtualItem<T> initialized with the specified data. |