Skip to content

refactor(login): resolve dependencies with Autofac#230

Open
luccas00 wants to merge 1 commit into
Matrix-Developers:mainfrom
luccas00:refactor/issue-216-autofac
Open

refactor(login): resolve dependencies with Autofac#230
luccas00 wants to merge 1 commit into
Matrix-Developers:mainfrom
luccas00:refactor/issue-216-autofac

Conversation

@luccas00

Copy link
Copy Markdown

Related issue

Closes #216

Problem

The login form manually instantiated the database context, repositories
and application services. It was also responsible for creating the main
form and supplying all of its dependencies.

This increased coupling between the presentation, application and
infrastructure layers, despite the project already using Autofac.

Solution

  • Removed manual dependency creation from TelaLogin;
  • Resolved TelaLogin through the Autofac container;
  • Injected only the FuncionarioAppService required for authentication;
  • Injected Func<TelaPrincipalForm> to defer creation of the main form;
  • Registered TelaLogin and TelaPrincipalForm in Autofac;
  • Delegated resolution of the main form and its dependencies to Autofac;
  • Removed unnecessary creation of an additional login form.

Validation

  • Application builds successfully;
  • Administrative login was validated;
  • The main form opens after authentication;
  • Database operations continue working correctly.

Files changed

  • TelaLogin.cs
  • AutoFac.cs
  • Program.cs

@luccas00
luccas00 marked this pull request as draft July 17, 2026 01:45
@luccas00

Copy link
Copy Markdown
Author

#230

@luccas00
luccas00 marked this pull request as ready for review July 17, 2026 01:46
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.

Refactor - Implementar injeção de dependência corretamente para a tela de login

1 participant