-
Notifications
You must be signed in to change notification settings - Fork 0
DiGi.Core.IO.File.Classes
Base class for files that support metadata and persistence via Zip archives.
public abstract class File : DiGi.Core.Classes.SerializableObject, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposableInheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File
Derived
↳ StorageFile<TSerializableObject>
↳ ValueFile<TSerializableObject>
↳ ValuesFile<TSerializableObject>
Implements DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
Initializes a new instance of the File class by cloning another file's metadata.
public File(DiGi.Core.IO.File.Classes.File? file);file File
The source file to clone metadata from.
Initializes a new instance of the File class with the specified path.
public File(string? path);path System.String
The path to the file.
Initializes a new instance of the File class from a JSON object.
public File(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object containing file data.
Gets the metadata storage of the file.
internal DiGi.Core.IO.Classes.MetadataStorage MetadataStorage { internal get; }DiGi.Core.IO.Classes.MetadataStorage
Gets or sets the path of the file.
public string? Path { get; set; }Releases all resources used by the file.
public void Dispose();Implements Dispose()
Retrieves metadata of the specified type from the file's metadata storage.
public TMetadata? GetMetadata<TMetadata>()
where TMetadata : DiGi.Core.IO.Interfaces.IMetadata;TMetadata
The type of metadata to retrieve.
TMetadata
The metadata of type TMetadata if found; otherwise, null.
Opens the file using its current path.
public virtual bool Open();Implements Open()
System.Boolean
True if the file was opened successfully; otherwise, false.
Opens the file from the specified path.
public bool Open(string? path);path System.String
The path of the file to open.
Implements Open(string)
System.Boolean
True if the file was opened successfully; otherwise, false.
Saves the file's metadata and updates its modification date.
public virtual bool Save();Implements Save()
System.Boolean
True if the save operation was successful; otherwise, false.
Saves the file to the specified path.
public bool SaveAs(string? path);path System.String
The path where the file should be saved.
Implements SaveAs(string)
System.Boolean
True if the file was saved successfully; otherwise, false.
Sets a custom metadata object for the file.
public void SetMetadata(DiGi.Core.IO.Interfaces.IMetadata? metadata);metadata DiGi.Core.IO.Interfaces.IMetadata
The metadata object to set.
Stores metadata for a file, including creation and modification dates, path, and type.
public class FileMetadata : DiGi.Core.Classes.GuidObject, DiGi.Core.IO.Interfaces.IMetadata, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject, DiGi.Core.Interfaces.IObject, DiGi.Core.IO.Wrapper.Interfaces.IWrapperObject, DiGi.Core.IO.Interfaces.IIOObjectInheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → DiGi.Core.Classes.UniqueObject → DiGi.Core.Classes.GuidObject → FileMetadata
Implements DiGi.Core.IO.Interfaces.IMetadata, DiGi.Core.Interfaces.ISerializableObject, DiGi.Core.Interfaces.ICloneableObject<DiGi.Core.Interfaces.ISerializableObject>, DiGi.Core.Interfaces.ICloneableObject, DiGi.Core.Interfaces.IObject, DiGi.Core.IO.Wrapper.Interfaces.IWrapperObject, DiGi.Core.IO.Interfaces.IIOObject
Initializes a new instance of the FileMetadata class by cloning another metadata object.
public FileMetadata(DiGi.Core.IO.File.Classes.FileMetadata? fileMetadata);fileMetadata FileMetadata
The source metadata object to clone.
Initializes a new instance of the FileMetadata class from a JSON object.
public FileMetadata(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object used to initialize the metadata.
Initializes a new instance of the FileMetadata class with type.
public FileMetadata(System.Type? type);type System.Type
The type to be associated with this metadata.
Initializes a new instance of the FileMetadata class with type and path.
public FileMetadata(System.Type? type, string? path);type System.Type
The type to be associated with this metadata.
path System.String
The file path to be associated with this metadata.
Gets the date and time when the file was created.
public System.DateTime Created { get; }Gets or sets the date and time when the file was last modified.
public System.DateTime Modified { get; set; }Gets or sets the path of the file.
public string? Path { get; set; }Gets the full type name of the file.
public string? Type { get; }Represents a file used for storing and managing serializable objects.
public class StorageFile : DiGi.Core.IO.File.Classes.StorageFile<DiGi.Core.Interfaces.ISerializableObject>Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File → DiGi.Core.IO.File.Classes.StorageFile<DiGi.Core.Interfaces.ISerializableObject> → StorageFile
Initializes a new instance of the StorageFile class from another storage file instance.
public StorageFile(DiGi.Core.IO.File.Classes.StorageFile? storageFile);storageFile StorageFile
The source storage file instance.
Initializes a new instance of the StorageFile class using the specified file path.
public StorageFile(string? path);path System.String
The path to the storage file.
Initializes a new instance of the StorageFile class from the provided JSON object.
public StorageFile(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object to initialize the storage file from.
Represents a file used for storing and managing serializable objects.
public class StorageFile<TSerializableObject> : DiGi.Core.IO.File.Classes.File, DiGi.Core.IO.File.Interfaces.IValuesFile<TSerializableObject>, DiGi.Core.IO.File.Interfaces.IValuesFile, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
where TSerializableObject : DiGi.Core.Interfaces.ISerializableObjectTSerializableObject
The type of serializable object that this storage file manages.
Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File → StorageFile<TSerializableObject>
Derived
↳ StorageFile
Implements DiGi.Core.IO.File.Interfaces.IValuesFile<TSerializableObject>, DiGi.Core.IO.File.Interfaces.IValuesFile, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
Initializes a new instance of the StorageFile class from an existing typed storage file.
public StorageFile(DiGi.Core.IO.File.Classes.StorageFile<TSerializableObject>? storageFile);storageFile DiGi.Core.IO.File.Classes.StorageFile<TSerializableObject>
The existing typed storage file to initialize from.
Initializes a new instance of the StorageFile class using the specified file path.
public StorageFile(string? path);path System.String
The system path to the storage file.
Initializes a new instance of the StorageFile class from the provided JSON object.
public StorageFile(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object used to initialize the storage file.
Gets the total number of elements contained in the storage file.
public int Count { get; }Gets all stored values as a collection of serializable objects.
public System.Collections.Generic.IEnumerable<TSerializableObject?>? Values { get; set; }Implements Values
System.Collections.Generic.IEnumerable<TSerializableObject>
Adds a serializable object to the storage and returns its unique reference.
public DiGi.Core.Classes.UniqueReference? AddValue(TSerializableObject? serializableObject);serializableObject TSerializableObject
The serializable object to be added to the storage.
DiGi.Core.Classes.UniqueReference
The unique reference of the added object, or null if the operation failed.
Determines whether the storage contains an object associated with the specified unique reference.
public bool Contains(DiGi.Core.Classes.UniqueReference? uniqueReference);uniqueReference DiGi.Core.Classes.UniqueReference
The unique reference to check for.
System.Boolean
True if the storage contains an object associated with the specified unique reference; otherwise, false.
Retrieves the unique reference for the specified serializable object.
public virtual DiGi.Core.Classes.UniqueReference? GetUniqueReference(TSerializableObject? serializableObject);serializableObject TSerializableObject
The serializable object to retrieve the reference for.
DiGi.Core.Classes.UniqueReference
The unique reference associated with the specified serializable object, or null.
Gets a set of all unique references stored in the file.
public System.Collections.Generic.HashSet<DiGi.Core.Classes.UniqueReference>? GetUniqueReferences();System.Collections.Generic.HashSet<DiGi.Core.Classes.UniqueReference>
A hash set containing all unique references stored in the file, or null.
Retrieves the typed value associated with the specified unique reference.
public TSerializableObject? GetValue(DiGi.Core.Classes.UniqueReference? uniqueReference);uniqueReference DiGi.Core.Classes.UniqueReference
The unique reference to retrieve the value for.
TSerializableObject
The typed value associated with the specified unique reference, or null if not found.
Retrieves the typed object at the specified index.
public TSerializableObject? GetValue(System.Nullable<int> index);index System.Nullable<System.Int32>
The index of the object to retrieve.
TSerializableObject
The typed object at the specified index, or null if not found.
Retrieves the base serializable object associated with the specified unique reference.
public USerializableObject? GetValue<USerializableObject>(DiGi.Core.Classes.UniqueReference? uniqueReference)
where USerializableObject : TSerializableObject;USerializableObject
The type of the serializable object.
uniqueReference DiGi.Core.Classes.UniqueReference
The unique reference to retrieve the value for.
USerializableObject
The base serializable object associated with the specified unique reference, or null if not found.
Retrieves the object at the specified index.
public USerializableObject? GetValue<USerializableObject>(int index)
where USerializableObject : TSerializableObject;USerializableObject
The type of serializable object to retrieve.
index System.Int32
The index of the object to retrieve.
USerializableObject
The object at the specified index, or null if not found.
Retrieves a typed collection of objects associated with the provided set of unique references.
public System.Collections.Generic.IEnumerable<TSerializableObject?>? GetValues(System.Collections.Generic.IEnumerable<DiGi.Core.Classes.UniqueReference>? uniqueReferences);uniqueReferences System.Collections.Generic.IEnumerable<DiGi.Core.Classes.UniqueReference>
The collection of unique references to retrieve values for.
System.Collections.Generic.IEnumerable<TSerializableObject>
A collection of typed objects associated with the provided unique references, or null if not available.
Retrieves a typed collection of objects at the specified indices.
public System.Collections.Generic.IEnumerable<TSerializableObject?>? GetValues(System.Collections.Generic.IEnumerable<int>? indexes);indexes System.Collections.Generic.IEnumerable<System.Int32>
The collection of indices for which to retrieve values.
System.Collections.Generic.IEnumerable<TSerializableObject>
A collection of typed objects corresponding to the provided indices, or null if not available.
Retrieves all stored objects as a collection.
public System.Collections.Generic.IEnumerable<USerializableObject?>? GetValues<USerializableObject>()
where USerializableObject : TSerializableObject;USerializableObject
The type of serializable objects being retrieved.
System.Collections.Generic.IEnumerable<USerializableObject>
A collection of all stored objects, or null if the collection is empty.
StorageFile<TSerializableObject>.GetValues<USerializableObject>(IEnumerable<UniqueReference>) Method
Retrieves a collection of objects associated with the provided set of unique references.
public System.Collections.Generic.IEnumerable<USerializableObject?>? GetValues<USerializableObject>(System.Collections.Generic.IEnumerable<DiGi.Core.Classes.UniqueReference>? uniqueReferences)
where USerializableObject : TSerializableObject;USerializableObject
The type of serializable object to retrieve.
uniqueReferences System.Collections.Generic.IEnumerable<DiGi.Core.Classes.UniqueReference>
The collection of unique references to retrieve values for.
System.Collections.Generic.IEnumerable<USerializableObject>
A collection of objects associated with the provided unique references, or null if not available.
Retrieves a collection of objects at the specified indices.
public System.Collections.Generic.IEnumerable<USerializableObject?>? GetValues<USerializableObject>(System.Collections.Generic.IEnumerable<int>? indexes)
where USerializableObject : TSerializableObject;USerializableObject
The type of serializable objects being retrieved.
indexes System.Collections.Generic.IEnumerable<System.Int32>
The collection of indices to retrieve objects from.
System.Collections.Generic.IEnumerable<USerializableObject>
A collection of objects found at the specified indices, or null if no objects were found.
Opens the storage file for reading and writing.
public override bool Open();Implements Open()
System.Boolean
True if the storage file was opened successfully; otherwise, false.
Removes the object associated with the specified unique reference.
public bool Remove(DiGi.Core.Classes.UniqueReference? uniqueReference);uniqueReference DiGi.Core.Classes.UniqueReference
The unique reference of the object to remove.
System.Boolean
True if the object was successfully removed; otherwise, false.
Removes all objects associated with the provided set of unique references.
public System.Collections.Generic.HashSet<DiGi.Core.Classes.UniqueReference>? Remove(System.Collections.Generic.IEnumerable<DiGi.Core.Classes.UniqueReference>? uniqueReferences);uniqueReferences System.Collections.Generic.IEnumerable<DiGi.Core.Classes.UniqueReference>
The collection of unique references to be removed.
System.Collections.Generic.HashSet<DiGi.Core.Classes.UniqueReference>
A HashSet containing the unique references that were successfully removed, or null if no objects were removed.
StorageFile<TSerializableObject>.RemoveAll<USerializableObject>(Func<USerializableObject,bool>) Method
Removes all objects that satisfy the specified condition and returns their references.
public System.Collections.Generic.HashSet<DiGi.Core.Classes.UniqueReference>? RemoveAll<USerializableObject>(System.Func<USerializableObject?,bool>? func)
where USerializableObject : TSerializableObject;USerializableObject
The type of the serializable objects being evaluated.
func System.Func<USerializableObject,System.Boolean>
A predicate function to determine which objects to remove.
System.Collections.Generic.HashSet<DiGi.Core.Classes.UniqueReference>
A set containing the unique references of all removed objects, or null if no objects were removed.
StorageFile<TSerializableObject>.RemoveFirst<USerializableObject>(Func<USerializableObject,bool>) Method
Removes the first object that satisfies the specified condition and returns its reference.
public DiGi.Core.Classes.UniqueReference? RemoveFirst<USerializableObject>(System.Func<USerializableObject?,bool>? func)
where USerializableObject : TSerializableObject;USerializableObject
The type of the serializable objects being evaluated.
func System.Func<USerializableObject,System.Boolean>
A predicate function to determine which object to remove.
DiGi.Core.Classes.UniqueReference
The unique reference of the removed object, or null if no object satisfied the condition.
Saves the current state of the storage file to disk.
public override bool Save();Implements Save()
System.Boolean
True if the save operation was successful; otherwise, false.
Attempts to retrieve a typed value for the specified unique reference.
public bool TryGetValue(DiGi.Core.Classes.UniqueReference? uniqueReference, out TSerializableObject? serializableObject);uniqueReference DiGi.Core.Classes.UniqueReference
The unique reference of the object to retrieve.
serializableObject TSerializableObject
When this method returns, contains the retrieved object if successful; otherwise, null.
System.Boolean
True if the object was successfully retrieved; otherwise, false.
Attempts to retrieve a typed value at the specified index.
public bool TryGetValue(int index, out TSerializableObject? serializableObject);index System.Int32
The zero-based index of the element to get.
serializableObject TSerializableObject
When this method returns, contains the object corresponding to the specified index, if found; otherwise, null.
System.Boolean
True if the element exists at the specified index; otherwise, false.
StorageFile<TSerializableObject>.TryGetValue<USerializableObject>(UniqueReference, USerializableObject) Method
Attempts to retrieve a base serializable object for the specified unique reference.
public bool TryGetValue<USerializableObject>(DiGi.Core.Classes.UniqueReference? uniqueReference, out USerializableObject? serializableObject)
where USerializableObject : TSerializableObject;USerializableObject
The type of the serializable object.
uniqueReference DiGi.Core.Classes.UniqueReference
The unique reference of the object to retrieve.
serializableObject USerializableObject
When this method returns, contains the retrieved object if successful; otherwise, null.
System.Boolean
True if the object was successfully retrieved; otherwise, false.
StorageFile<TSerializableObject>.TryGetValue<USerializableObject>(Nullable<int>, USerializableObject) Method
Attempts to retrieve a base serializable object at the specified index.
public bool TryGetValue<USerializableObject>(System.Nullable<int> index, out USerializableObject? serializableObject)
where USerializableObject : TSerializableObject;USerializableObject
The type of the serializable object.
index System.Nullable<System.Int32>
The zero-based index of the element to get.
serializableObject USerializableObject
When this method returns, contains the object corresponding to the specified index, if found; otherwise, null.
System.Boolean
True if the element exists at the specified index; otherwise, false.
Represents a file that stores a single value.
public class ValueFile : DiGi.Core.IO.File.Classes.ValueFile<DiGi.Core.Interfaces.ISerializableObject>Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File → DiGi.Core.IO.File.Classes.ValueFile<DiGi.Core.Interfaces.ISerializableObject> → ValueFile
Initializes a new instance of the ValueFile class from an existing non-generic value file.
public ValueFile(DiGi.Core.IO.File.Classes.ValueFile? valueFile);valueFile ValueFile
The existing non-generic value file to initialize from.
Initializes a new instance of the ValueFile class using the specified file path.
public ValueFile(string? path);path System.String
The path to the value file.
Initializes a new instance of the ValueFile class from the provided JSON object.
public ValueFile(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object to initialize the value file from.
Represents a file that stores a single value.
public class ValueFile<TSerializableObject> : DiGi.Core.IO.File.Classes.File, DiGi.Core.IO.File.Interfaces.IValueFile<TSerializableObject>, DiGi.Core.IO.File.Interfaces.IValueFile, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
where TSerializableObject : DiGi.Core.Interfaces.ISerializableObjectTSerializableObject
The type of the serializable object stored in the file.
Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File → ValueFile<TSerializableObject>
Derived
↳ ValueFile
Implements DiGi.Core.IO.File.Interfaces.IValueFile<TSerializableObject>, DiGi.Core.IO.File.Interfaces.IValueFile, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
Initializes a new instance of the ValueFile class from an existing generic value file.
public ValueFile(DiGi.Core.IO.File.Classes.ValueFile<TSerializableObject>? valueFile);valueFile DiGi.Core.IO.File.Classes.ValueFile<TSerializableObject>
The existing generic value file to initialize from.
Initializes a new instance of the ValueFile class using the specified file path.
public ValueFile(string? path);path System.String
The path to the value file.
Initializes a new instance of the ValueFile class from the provided JSON object.
public ValueFile(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object to initialize from.
Gets or sets the value stored within the file.
public TSerializableObject? Value { get; set; }Implements Value
Opens the file and loads its content into memory.
public override bool Open();Implements Open()
System.Boolean
True if the open operation was successful; otherwise, false.
Saves the current state of the object to the file.
public override bool Save();Implements Save()
System.Boolean
True if the save operation was successful; otherwise, false.
ValueFile<TSerializableObject>.explicit operator TSerializableObject(ValueFile<TSerializableObject>) Operator
Explicitly converts a ValueFile<TSerializableObject> to its contained value of type TSerializableObject.
public static TSerializableObject? explicit operator TSerializableObject?(DiGi.Core.IO.File.Classes.ValueFile<TSerializableObject>? valueFile);valueFile DiGi.Core.IO.File.Classes.ValueFile<TSerializableObject>
The value file to convert.
TSerializableObject
The contained value, or the default value if the file is null.
Represents a file that stores a collection of values.
public class ValuesFile : DiGi.Core.IO.File.Classes.ValuesFile<DiGi.Core.Interfaces.ISerializableObject>Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File → DiGi.Core.IO.File.Classes.ValuesFile<DiGi.Core.Interfaces.ISerializableObject> → ValuesFile
Initializes a new instance of the ValuesFile class from an existing non-generic values file.
public ValuesFile(DiGi.Core.IO.File.Classes.ValuesFile? valuesFile);valuesFile ValuesFile
The existing non-generic values file to initialize from.
Initializes a new instance of the ValuesFile class using the specified file path.
public ValuesFile(string? path);path System.String
The path to the values file.
Initializes a new instance of the ValuesFile class from the provided JSON object.
public ValuesFile(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object to initialize from.
Represents a file that stores a collection of values.
public class ValuesFile<TSerializableObject> : DiGi.Core.IO.File.Classes.File, DiGi.Core.IO.File.Interfaces.IValuesFile<TSerializableObject>, DiGi.Core.IO.File.Interfaces.IValuesFile, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
where TSerializableObject : DiGi.Core.Interfaces.ISerializableObjectTSerializableObject
The type of the serializable object stored in the file.
Inheritance System.Object → DiGi.Core.Classes.Object → DiGi.Core.Classes.SerializableObject → File → ValuesFile<TSerializableObject>
Derived
↳ ValuesFile
Implements DiGi.Core.IO.File.Interfaces.IValuesFile<TSerializableObject>, DiGi.Core.IO.File.Interfaces.IValuesFile, DiGi.Core.IO.File.Interfaces.IFile, System.IDisposable
Initializes a new instance of the ValuesFile class from an existing generic values file.
public ValuesFile(DiGi.Core.IO.File.Classes.ValuesFile<TSerializableObject>? valuesFile);valuesFile DiGi.Core.IO.File.Classes.ValuesFile<TSerializableObject>
The existing generic values file to initialize from.
Initializes a new instance of the ValuesFile class using the specified file path.
public ValuesFile(string? path);path System.String
The path to the values file.
Initializes a new instance of the ValuesFile class from the provided JSON object.
public ValuesFile(System.Text.Json.Nodes.JsonObject? jsonObject);jsonObject System.Text.Json.Nodes.JsonObject
The JSON object to initialize from.
Gets or sets the collection of values stored within the file.
public System.Collections.Generic.IEnumerable<TSerializableObject?>? Values { get; set; }Implements Values
System.Collections.Generic.IEnumerable<TSerializableObject>
Opens the file and loads its content into memory.
public override bool Open();Implements Open()
System.Boolean
True if the open operation was successful; otherwise, false.
Saves the current state of the object to the file.
public override bool Save();Implements Save()
System.Boolean
True if the save operation was successful; otherwise, false.