CastelloBranco.LocatorGenerator
2.1.3
dotnet add package CastelloBranco.LocatorGenerator --version 2.1.3
NuGet\Install-Package CastelloBranco.LocatorGenerator -Version 2.1.3
<PackageReference Include="CastelloBranco.LocatorGenerator" Version="2.1.3" />
paket add CastelloBranco.LocatorGenerator --version 2.1.3
#r "nuget: CastelloBranco.LocatorGenerator, 2.1.3"
// Install CastelloBranco.LocatorGenerator as a Cake Addin #addin nuget:?package=CastelloBranco.LocatorGenerator&version=2.1.3 // Install CastelloBranco.LocatorGenerator as a Cake Tool #tool nuget:?package=CastelloBranco.LocatorGenerator&version=2.1.3
CastelloBranco.LocatorGenerator
CastelloBranco.LocatorGenerator is a source generator designed to automatically generate the necessary code to locate and instantiate ViewModels marked with a special attribute in Avalonia projects.
Usage
Inports nuget Package AutoRegisterInject and decorate yours views and viewmodels with
[RegisterTransient] [RegisterSingleton] [RegisterScoped] [RegisterHostedService]
Code Generator
This tool scans projects for classes and generates a ViewLocator.g.cs
file to resolve and inject dependencies automatically using the CommunityToolkit.Mvvm library.
Setup
NuGet Package:
1) Add nuget packeges to the project that will use the generated locator.
Microsoft.Extensions.DependencyInjection;
CommunityToolkit.Mvvm
AutoRegisterInject
2) Add the `CastelloBranco.LocatorGenerator` package to the project that will use the generated locator.
Usage
- Decorate yours views and viewmodels with
[RegisterTransient] [RegisterSingleton] [RegisterScoped] [RegisterHostedService]
- in xaml files add the following namespaces and AutoWrireViewModel.Enabled="True"
<UserControl
...
xmlns:l="using:your_root_namespace"
xmlns:views="using:your_Views_namespace_"
xmlns:vm="using:your_ViewModels_namespace_"
l:AutoWireViewModel.Enabled="True"
x:DataType="vm:MainViewViewModel"
>
- Add the following code to the App.xaml file
<Application ...
xmlns:l="using:your_root_namespace"
... >
<Application.DataTemplates>
<l:ViewLocator />
</Application.DataTemplates>
License
MIT
Contribution
Contributions are welcome! Please follow the pull request process and review our contribution policy.
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- AutoRegisterInject (>= 1.4.1)
- CommunityToolkit.Mvvm (>= 8.4.0)
- Microsoft.Extensions.DependencyInjection (>= 9.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.