IInitialize 1.0.3
See the version list below for details.
dotnet add package IInitialize --version 1.0.3
NuGet\Install-Package IInitialize -Version 1.0.3
<PackageReference Include="IInitialize" Version="1.0.3" />
<PackageVersion Include="IInitialize" Version="1.0.3" />
<PackageReference Include="IInitialize" />
paket add IInitialize --version 1.0.3
#r "nuget: IInitialize, 1.0.3"
#:package IInitialize@1.0.3
#addin nuget:?package=IInitialize&version=1.0.3
#tool nuget:?package=IInitialize&version=1.0.3
Description
IInitialize is an interface that defines a contract for initialization processing. Implementing this interface indicates that an object requires an initialization phase.
This interface provides a single event, Initialize, which is raised when the initialization process is complete.
The Initialize event uses the generic InitializeEventHandler<TSender> delegate, where TSender represents the type of the object that raised the event. Event handlers receive an InitializeEventArgs object, which can contain arguments related to the initialization process, such as information about already initialized properties.
By utilizing this interface, other components or services can asynchronously be notified of the initialization completion of objects implementing IInitialize. This can be useful for scenarios such as starting dependent processes or updating the UI after initialization.
Key Elements:
- IInitialize(Of TSender): The interface to be implemented by objects requiring initialization.
TSenderspecifies the type of the object raising the event. - InitializeEventHandler(Of TSender) Delegate: Defines the type for the
Initializeevent's handlers. - Initialize Event: An event that is raised when initialization processing is complete.
- InitializeEventArgs Class: Provides arguments related to the event, such as information about already initialized properties.
Providing this interface as a library allows you to establish a consistent initialization pattern across your applications, improving code reusability and maintainability.
(Usage Example for C# Developers):
Here's a basic example of how a C# class might implement and use the IInitialize interface, noting that InitializeEventArgs is nullable:
public class MyService : IInitialize<MyService>
{
public event InitializeEventHandler<MyService> Initialize;
public void BeginInitialization()
{
// Perform initialization tasks here
Console.WriteLine("MyService is initializing...");
OnInitialize(null); // InitializeEventArgs can be null
}
protected virtual void OnInitialize(InitializeEventArgs? e)
{
Initialize?.Invoke(this, e);
}
}
public class Consumer
{
public Consumer(MyService service)
{
service.Initialize += (sender, e) =>
{
Console.WriteLine("MyService has been initialized!");
// Perform actions that depend on MyService being initialized
};
}
}
Release Notes
Version 1.0.0 Release Notes
Introduction of the IInitialize(Of TSender) Interface:
- Introduced the
IInitialize(Of TSender)interface, which defines an event related to initialization processing. - Implementing this interface indicates that an object requires an initialization phase.
- Defines the
Initializeevent of typeInitializeEventHandler(Of TSender).
- Introduced the
Introduction of the InitializeEventArgs Structure:
- Introduced the
InitializeEventArgsstructure, which stores event arguments related to initialization processing. - This structure is nullable, so pay attention to the nullable operator.
- Contains a nested structure
AlreadyInitializedPropertyto store information about already initialized properties. - The
AlreadyInitializedPropertystructure stores the name and value of an already initialized property and has a constructor that takes these as arguments. - The
InitializeEventArgsstructure has anAlreadyInitializedproperty that gets the collection of already initialized properties. - The
InitializeEventArgsstructure has constructors that accept either anIEnumerable(Of AlreadyInitializedProperty)or a variable number ofAlreadyInitializedPropertyobjects as arguments.
- Introduced the
Introduction of the InitializeEventHandler(Of TSender) Delegate:
- Introduced the
InitializeEventHandler(Of TSender)delegate, which represents a handler for events related to initialization processing. - Takes the object that raised the event and an
InitializeEventArgsobject containing arguments related to the event as parameters.
- Introduced the
Version 1.0.1 Release Notes
- The author has been changed.
Version 1.0.2 Release Notes
- Constructor Added to InitializeEventArgs Structure:
- Added a new constructor to the
InitializeEventArgsstructure that accepts a variable number ofAlreadyInitializedPropertyobjects as arguments. - This allows for easier creation of
InitializeEventArgsinstances by individually specifying already initialized properties.
- Added a new constructor to the
Example:
InitializeEventArgs args = new InitializeEventArgs(
new AlreadyInitializedProperty("Property1", 1),
new AlreadyInitializedProperty("Property2", "value")
);
Version 1.0.3 Release Notes
This release introduces the InitializeEventArgs structure for storing event arguments related to initialization processing, along with the associated collection class PropertyInfoCollection, and the InitializationState class for managing the state of initialization.
Main Changes
InitializeEventArgs Structure
- Stores event arguments related to initialization processing.
- Contains an inner structure
AlreadyInitializedPropertyto store the name and value of properties that have already been initialized. - Has a
Stateproperty (PropertyInfoCollection(Of InitializationState)) to manage the state of the initialization process. - Has an
AlreadyInitializedproperty (PropertyInfoCollection(Of AlreadyInitializedProperty)) to store a collection of properties that have already been initialized. - Provides constructors that accept either an
IEnumerable(Of AlreadyInitializedProperty)or aParamArrayofAlreadyInitializedPropertyobjects.
PropertyInfoCollection(Of T) Class
- Represents a generic collection of unique elements.
- Uses
HashSet(Of T)internally for fast addition and retrieval of elements. - Provides
Addmethod,Containsmethod, andCountproperty. - Provides a constructor that accepts an
IEnumerable(Of T)to initialize the collection.
InitializationState Class
- Stores the state of the initialization process (success/failure, description, etc.).
- Has
IsSuccessfulproperty (indicating whether initialization was successful) andDescriptionproperty (describing the state). - Has
Nameproperty andValueproperty (through implementation of theIPropertyInfointerface). - Provides a constructor that accepts
Name,Value,IsSuccessful, andDescriptionas arguments.
These changes allow for more structured management of the initialization process state and information about already initialized properties.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initial release of the IInitialize interface and related types.