Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use IoC Container #258

Merged
merged 3 commits into from
Feb 12, 2025
Merged

Use IoC Container #258

merged 3 commits into from
Feb 12, 2025

Conversation

SuperJMN
Copy link
Contributor

@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
Contributor 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
Contributor 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
Contributor 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