-
Notifications
You must be signed in to change notification settings - Fork 12
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
Register for DefaultDataObjectEdmModelBuilder #283
Conversation
{ | ||
public class DataObjectEdmModelDependencies | ||
{ | ||
public IExportService ExportService; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
для корректности вероятно у свойств должно быть public get и private set.
NewPlatform.Flexberry.ORM.ODataService/Model/DataObjectEdmModelDependencies.cs
Show resolved
Hide resolved
@@ -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); |
There was a problem hiding this comment.
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>(); |
There was a problem hiding this comment.
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; } |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Непонятно. У конструктора 6 параметров, а у тебя тут только 3.
No description provided.