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

Register for DefaultDataObjectEdmModelBuilder #283

Conversation

torres6093
Copy link

No description provided.

{
public class DataObjectEdmModelDependencies
{
public IExportService ExportService;
Copy link
Contributor

Choose a reason for hiding this comment

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

для корректности вероятно у свойств должно быть public get и private set.

@@ -28,7 +28,7 @@ public void TestDataObjectIsNotRegisteredInEmptyModel()
[Fact]
public void TestRegisteringHierarchy()
{
var builder = new DefaultDataObjectEdmModelBuilder(new[] { GetType().Assembly });
var builder = new DefaultDataObjectEdmModelBuilder(new[] { GetType().Assembly }, null);
Copy link
Contributor

Choose a reason for hiding this comment

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

И будет ArgumentNullException(nameof(serviceProvider)).
Вероятно, нужно сервис провайдер тестовый создать и его тут передавать.

var securityManager = new EmptySecurityManager();
Mock<IAuditService> mockAuditService = new Mock<IAuditService>();
Mock<IBusinessServerProvider> mockBusinessServerProvider = new Mock<IBusinessServerProvider>();
IDataService dataService = new PostgresDataService(securityManager, mockAuditService.Object, mockBusinessServerProvider.Object) { CustomizationString = CustomizationString };

unityContainer.RegisterType<DataObjectEdmModelDependencies>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Нам нужна не просто сущность класса DataObjectEdmModelDependencies. Если сделать так, то параметры просто разрешатся дефолтными для соответствующих интерфейсов.

IExportService exportService,
IExportService exportServiceNamed,
IExportStringedObjectViewService exportStringedObjectViewService,
IExportStringedObjectViewService exportStringedObjectViewServiceNamed,
IODataExportService oDataExportService,
IODataExportService oDataExportServiceNamed

Нам нужна регистрация по типу
"container.RegisterType(new InjectionConstructor(container.Resolve("emptyUser")));", причём нужен синглтон (не помню, вроде тут ещё параметр нужно указать).

/// </summary>
public class DataObjectEdmModelDependencies
{
public IExportService ExportService { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

К публичным свойствам и конструкторам нужно прописывать комментарии.

using NewPlatform.Flexberry.ORM.ODataService.Model;
using Unity;
using System;
Copy link
Contributor

Choose a reason for hiding this comment

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

Порядок юзингов важен. Сначала System в алфавитном порядке. Потом через пустую строчку остальные в алфавитном порядке. (По идее студия это подсказывает).


unityContainer.RegisterType<DataObjectEdmModelDependencies>(
new InjectionConstructor(
new ResolvedParameter<IExportService>("Export"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Непонятно. У конструктора 6 параметров, а у тебя тут только 3.

@Anisimova2020 Anisimova2020 merged commit b83e09a into Flexberry:feature-239-use-proper-di Jun 1, 2023
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