Fast.Activator
2.2.0
dotnet add package Fast.Activator --version 2.2.0
NuGet\Install-Package Fast.Activator -Version 2.2.0
<PackageReference Include="Fast.Activator" Version="2.2.0" />
paket add Fast.Activator --version 2.2.0
#r "nuget: Fast.Activator, 2.2.0"
// Install Fast.Activator as a Cake Addin #addin nuget:?package=Fast.Activator&version=2.2.0 // Install Fast.Activator as a Cake Tool #tool nuget:?package=Fast.Activator&version=2.2.0
FastActivator
FastActivator is a C# library that provides a faster alternative to the System.Activator
class for creating instances of classes.
Purpose
The purpose of FastActivator is to replace the usage of System.Activator
with a more efficient implementation, resulting in improved performance when creating instances of classes.
Speed Comparisons
Method | Mean | Error | StdDev | Rank | Gen0 | Allocated |
---|---|---|---|---|---|---|
ActivatorCreateInstance | 182.80 ns | 1.272 ns | 1.127 ns | 2 | 0.0401 | 336 B |
FastActivatorCreateInstance | 28.27 ns | 0.422 ns | 0.352 ns | 1 | 0.0115 | 96 B |
In many instances it's about 2x to 10x faster depending on the method used.
Usage
To use FastActivator, follow these steps:
Add a reference to the FastActivator library in your project.
dotnet add package Fast.Activator
Import the required namespaces:
using Fast.Activator;
To create an instance of a class using FastActivator, use one of the following methods:
CreateInstance<TClass>(params object[] args)
: Creates an instance of the specified classTClass
with the provided arguments, if any.var instance = FastActivator.CreateInstance<MyClass>(arg1, arg2);
CreateInstance<TClass>()
: Creates an instance of the specified classTClass
without any arguments.var instance = FastActivator.CreateInstance<MyClass>();
CreateInstance(Type type, params object[] args)
: Creates an instance of the specifiedType
with the provided arguments, if any.var instance = FastActivator.CreateInstance(typeof(MyClass), arg1, arg2);
CreateInstance(Type type)
: Creates an instance of the specifiedType
without any arguments.var instance = FastActivator.CreateInstance(typeof(MyClass));
Note: If the object cannot be created, the methods will return
null
.
Contributing
Contributions to FastActivator are welcome! If you would like to contribute, please follow these guidelines:
Fork the repository and create a new branch for your feature or bug fix.
Make your changes and ensure that the tests pass.
Submit a pull request describing your changes and the problem they solve.
Ensure that your code adheres to the project's coding conventions and style guidelines.
License
FastActivator is released under the Apache 2.0 License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. |
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Fast.Activator:
Package | Downloads |
---|---|
Canister.IoC
Canister adds functionality to the IServiceCollection including adding all objects of a certain type, automatic registration of types via modules, etc. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.2.0 | 314 | 11/16/2024 |
2.1.5 | 17,156 | 8/21/2024 |
2.1.4 | 63,934 | 3/13/2024 |
2.1.3 | 7,763 | 2/21/2024 |
2.1.2 | 8,967 | 2/1/2024 |
2.1.1 | 6,222 | 1/28/2024 |
2.1.0 | 11,473 | 12/10/2023 |
2.0.26 | 5,620 | 11/16/2023 |
2.0.25 | 16,189 | 9/8/2023 |
2.0.24 | 3,275 | 9/4/2023 |
2.0.23 | 3,872 | 8/30/2023 |
2.0.22 | 3,330 | 8/28/2023 |
2.0.21 | 7,452 | 8/7/2023 |
2.0.20 | 7,595 | 7/12/2023 |
2.0.19 | 2,617 | 7/9/2023 |
2.0.18 | 2,366 | 7/7/2023 |
2.0.17 | 153 | 7/7/2023 |
2.0.4 | 165 | 6/30/2023 |
2.0.3 | 156 | 6/30/2023 |
2.0.2 | 141 | 6/30/2023 |
2.0.1 | 411 | 12/13/2022 |
2.0.0 | 6,676 | 12/11/2022 |
1.0.20 | 16,493 | 6/6/2022 |
1.0.18 | 1,178 | 2/25/2022 |
1.0.17 | 10,359 | 1/11/2022 |
1.0.16 | 29,983 | 5/19/2021 |
1.0.15 | 1,821 | 4/26/2021 |
1.0.14 | 2,518 | 4/22/2021 |
1.0.13 | 9,637 | 1/6/2021 |
1.0.12 | 385 | 1/6/2021 |
1.0.10 | 11,620 | 9/13/2020 |
1.0.9 | 17,590 | 4/16/2020 |
1.0.8 | 2,330 | 4/15/2020 |
1.0.6 | 2,028 | 4/15/2020 |
1.0.5 | 449 | 4/15/2020 |
1.0.4 | 2,208 | 4/15/2020 |