Skip to content

Use IoC Container#258

Merged
dangershony merged 3 commits intoblock-core:mainfrom
SuperJMN:composition
Feb 12, 2025
Merged

Use IoC Container#258
dangershony merged 3 commits intoblock-core:mainfrom
SuperJMN:composition

Conversation

@SuperJMN
Copy link
Collaborator

@SuperJMN SuperJMN commented Feb 12, 2025

Use Microsoft.Extensions.DependencyInjection to better handling of dependencies.

Includes:

  • Move UI Services to appropriate folder
  • Move Sections to own folder

{
var services = new ServiceCollection();

services
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will also at some point have to add all the angor services, it is a good idea to do it this way, we can also add later a method .AddAngorServices()

namespace AngorApp.Composition;

public class SectionsFactory(IServiceProvider serviceProvider) : ISectionsFactory
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are sections exactly? is this like sections of the UI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the sections that appear in the Sidebar. Their have a ViewModel as content, and they are lazily loaded as needed.

Position = NotificationPosition.BottomRight
}
))
.AddSingleton<UIServices>(sp => new UIServices(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't all those services just get resolved automatically? why this hack?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right. Leftover from previous code... Will fix!

{
var loggerFactory = LoggerConfig.CreateFactory();
return new ProjectService(
DependencyFactory.GetIndexerService(loggerFactory),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normally we do not pass the logger factory to services do we?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dangershony dangershony merged commit bff0434 into block-core:main Feb 12, 2025
3 checks passed
@SuperJMN SuperJMN deleted the composition branch February 14, 2025 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants