lefttwixwand / inventory Goto Github PK
View Code? Open in Web Editor NEWNew version of Microsoft Inventory sample, built on WinUI 3, using DDD and Clean Architecture approach
License: MIT License
New version of Microsoft Inventory sample, built on WinUI 3, using DDD and Clean Architecture approach
License: MIT License
How can background services be added as used to be in UWP ?
At the current moment the image conversion works using ImageConverter
class with async method to convert image from byte array to ImageSource. It's not the best coise to perform such conversion at the mapping time.
So, it would be better to implement somehow async ValueConverter and convert bytes to ImageSource on Presentation layer side.
And one of such cases I found on the Stack Overflow: https://stackoverflow.com/questions/15003827/async-implementation-of-ivalueconverter
The WinUI can't inherit default style.
The issue related to the microsoft-ui-xaml
issue 6674
I'm trying to store events in the Warehouses table per product id.
And all the events are inherited from WarehouseEventBase
.
But now it's impossible to have TPH (Table Per Hierarchy) with owned types, like this:
internal sealed class WarehouseEntityTypeConfiguration : IEntityTypeConfiguration<Warehouse>
{
public void Configure(EntityTypeBuilder<Warehouse> builder)
{
builder.ToTable("Warehouses");
builder.HasKey(warehouse => warehouse.ProductId);
builder.Property(warehouse => warehouse.ProductId)
.HasColumnName(nameof(Product.Id))
.HasConversion(id => id.Value, value => new ProductId(value));
builder.OwnsMany(warehouse => warehouse.DomainEvents, navigationBuilder =>
{
navigationBuilder.UsePropertyAccessMode(PropertyAccessMode.Field);
});
}
}
internal sealed class WarehouseEventBaseTypeConfiguration : IEntityTypeConfiguration<WarehouseEventBase>
{
public void Configure(EntityTypeBuilder<WarehouseEventBase> builder)
{
builder.HasDiscriminator<string>(nameof(WarehouseEventBase))
.HasValue<WarehouseCreatedEvent>(nameof(WarehouseCreatedEvent))
.HasValue<ProductsShippedEvent>(nameof(ProductsShippedEvent))
.HasValue<ProductsMissedEvent>(nameof(ProductsMissedEvent))
.HasValue<ProductsReceivedEvent>(nameof(ProductsReceivedEvent));
}
}
This behavior should be implemented as soon as the feature will be added to ef core 8.
Related issue: dotnet/efcore#9630
Whereas the app should have a local dB and work offline, it would be great to demonstrate how to integrate and authentic with a Azure hosted database to pull products and customers at the same time submit all orders to the api in the background without a user trigger
Check, if it's possible to use init only properties in the Domain models.
Init keyword docs: docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/init
A month ago, MediatR 10 was presented.
The main future - support of IAsyncEnumerable
request result, which is significant improvement.
Migration docks:
It's needed to review Microsoft Inventory Sample, and segregate the domain layer with its business logic.
The main points:
Now INavigationAware
interface looks like this:
public interface INavigationAware
{
void OnNavigatedTo(object parameter);
void OnNavigatedFrom();
}
Current implementation is not correct from the architecture point of view. It forces us to have both methods, when one of them might be surplus.
public async void OnNavigatedTo(object parameter)
{
if (parameter is long orderId)
{
// Do some stuff
}
}
public void OnNavigatedFrom()
{
// Useless
}
Like SOLID Interface Segregation Principle says: Clients should not be forced to implement any methods they don’t use
That's why it would be better to split INavigationAware
into two separate interfaces INavigatedTo
and INavigatedFrom
.
And as a part of code enhancement, it might be possible to make a parameter in OnNavigatedTo(object parameter)
strongly typed for the cases, where we have only one possible navigation scenario.
public interface INavigatedTo<T>
{
void OnNavigatedTo(T parameter);
}
public interface INavigatedTo : INavigatedTo<object>
{
}
public interface INavigatedFrom
{
void OnNavigatedFrom();
}
It would be better to use andrewlock/StronglyTypedId to simplify the code.
It would be good to have a central package management in this project, based on this article: Introducing Central Package Management.
Also, it would be great to add Dependabot for automatic package update.
Now the application toolbar is manually extended to match the Windows 11 style system.
But every time the theme has changed, we have to apply the toolbar style manually:
To avoid the code-behind, we can use the ThemeListener from the Community Toolkit to subscribe for the system theme change (if application theme is default) and handle it automatically in the separate service.
Add printing of documents. I.e orders printing
Examples of binding checkbox control to UI.
I.e Is Active field on the products table.
Issue #28 describes how to use CommunityToolkit.Mvvm.Messaging for ViewModels communication. The only one problem here, is every ViewModel which listens for a message, has to be manually activated: IsActive = true;
to start listening.
So, it would be good to automatically activate such ViewModels somewhere in the NavigationService
.
As a bad solution - all the ObservableRecipient
instances can be activated in the Autofac container callback after they've being resolved.
CommunityToolkit.Mvvm.Messaging provides IMessenger
interface, that allows us to set up Pub / Sub system for flexible ViewModels communication.
How it can be useful?
We have a ProductsView
with ProductsViewModel
, which has a list of products.
And a ProductView
with ProductViewModel
, where we can see some detail information, modify it, delete current product or to add a new one.
After we added, edited or deleted a product - we can just send a message, what we've modified.
And the main ProductsViewModel
will handle it and will update its collection.
So, we won't need to load all the products from the database after every modification - we just will need to update im-memoty Observable collection.
// Define a message
public sealed class ProductDeletedMessage : ValueChangedMessage<int>
{
public ProductDeletedMessage(int productId) : base(productId)
{
}
}
// Send a message
public sealed partial class ProductViewModel : ObservableObject
{
[RelayCommand]
private void DeleteItem(int productId)
{
WeakReferenceMessenger.Default.Send(new ProductDeletedMessage(productId));
}
}
// Handle a message
public sealed partial class ProductsViewModel : ObservableRecipient, IRecipient<ProductDeletedMessage>
{
public ProductsViewModel()
{
// Activate message listener
IsActive = true;
}
public ObservableCollection<ProductModel> Products { get; } = new();
public void Receive(ProductDeletedMessagemessage)
{
var productToDelete = Products.First(prodcut => prodcut.Id == message.Value);
Products.Remove(productToDelete);
}
}
CommunityToolkit.Helpers.ObjectStorage allows to easily store some data in LocalObjectStorage or RoamingObjectStorage, which makes LocalSettingsService
not actual. Or at least it requires some refactoring to use provided by CommunityToolkit functionality.
Research the possibility to use Mapster.EFCore for domain entities mapping in Persistance.Database
queries.
Create an example of using XAML Island in Win Forms app to show a "new" version of the app with new UI by integration some of the WinUI components into a WinForms app.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.