Neatoo.RemoteFactory.AspNetCore
9.19.1
dotnet add package Neatoo.RemoteFactory.AspNetCore --version 9.19.1
NuGet\Install-Package Neatoo.RemoteFactory.AspNetCore -Version 9.19.1
<PackageReference Include="Neatoo.RemoteFactory.AspNetCore" Version="9.19.1" />
<PackageVersion Include="Neatoo.RemoteFactory.AspNetCore" Version="9.19.1" />
<PackageReference Include="Neatoo.RemoteFactory.AspNetCore" />
paket add Neatoo.RemoteFactory.AspNetCore --version 9.19.1
#r "nuget: Neatoo.RemoteFactory.AspNetCore, 9.19.1"
#:package Neatoo.RemoteFactory.AspNetCore@9.19.1
#addin nuget:?package=Neatoo.RemoteFactory.AspNetCore&version=9.19.1
#tool nuget:?package=Neatoo.RemoteFactory.AspNetCore&version=9.19.1
Remote Factory
Neatoo Remote Factory is a Data Mapper Factory for Domain Models powered by Roslyn Source Generators. It allows Domain Model objects to be 3-Tier client/server and authentication agnostic. Used with Neatoo you can create streamlined Rich Domain Models in .NET with authorization, business rules, data-binding and meta properties. All with a single controller and no DTOs*. It is Dependency Injection and Async/Await centric. Plus high performance thanks to the source generators.
Create streamlined Blazor and WPF applications with Neatoo!
Videos
Example
Here is the factory interface generated by Neatoo Remote Factory using a Roslyn Source Generator for the PersonModel object class. It also generates the implementation.
public interface IPersonModelFactory
{
IPersonModel? Create();
Task<IPersonModel?> Fetch();
Task<IPersonModel?> Save(IPersonModel target);
Task<Authorized<IPersonModel>> TrySave(IPersonModel target);
Authorized CanCreate();
Authorized CanFetch();
Authorized CanUpdate();
Authorized CanInsert();
Authorized CanDelete();
Authorized CanSave();
}
See the Person Demo example shown in the animation below. Given a domain model object and optional authorization object the factory is generated by Neatoo using that provides 3-Tier implementation and ties in the authorization.
*No Dtos for the UI to Service/Application layer. Other patterns like repository may require DTOs.
Getting Started
To get started with Neatoo Remote Factory, follow these steps:
1. Install the Neatoo Remote Factory NuGet package in your client and server projects.
2. Register the necessary services in ASP.NET server application. Be sure to include your Domain Model library assembly.
builder.Services.AddNeatooRemoteFactory(NeatooFactory.Server, typeof(IPersonModel).Assembly);
3. Add a single controller to your ASP.NET server application
app.MapPost("/api/neatoo", (HttpContext httpContext, RemoteRequestDto request) =>
{
var handleRemoteDelegateRequest = httpContext.RequestServices.GetRequiredService<HandleRemoteDelegateRequest>();
return handleRemoteDelegateRequest(request);
});
4. In your client application, register the Neatoo Remote Factory services Note: Update the URL in the following code.
builder.Services.AddNeatooRemoteFactory(NeatooFactory.Remote, typeof(IPersonModel).Assembly);
builder.Services.AddKeyedScoped(Neatoo.RemoteFactory.RemoteFactoryServices.HttpClientKey, (sp, key) => {
return new HttpClient { BaseAddress = new Uri("http://localhost:5183/") };
});
5. Create a domain model class and add the [Factory] attribute
[Factory]
public class PersonModel : IPersonModel
{
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
6. Add Factory Operation methods including Create, Fetch, Update, Insert and Delete
...
[Fetch]
public async Task<bool> Fetch([Service] IPersonContext personContext)
{
var personEntity = await personContext.Persons.FirstOrDefaultAsync(x => x.Id == 1);
if (personEntity == null)
{
return false;
}
this.MapFrom(personEntity);
this.IsNew = false;
return true;
}
7. Neato Remote Factory will use Roslyn to automatically generate a corresponding factory class
public interface IPersonModelFactory
{
IPersonModel? Create();
Task<IPersonModel?> Fetch();
Task<IPersonModel?> Save(IPersonModel target);
}
Example
For an example Blazor Standalone application see here. It shows all of the available operations: Create, Fetch, Insert, Update and Delete. It also shows how to add Authorization. For now, you do need to load the entire solution. You also need to deploy the EF database migrations.
Please reach out to me if you have any interest. More to come!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Neatoo.RemoteFactory (>= 9.19.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
None yet