-
Notifications
You must be signed in to change notification settings - Fork 13
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 unity without config file #286
base: feature-239-use-proper-di
Are you sure you want to change the base?
Changes from 3 commits
20c2596
e98f96a
961acfb
8ed8b3d
69973bf
dbe76d4
cebb4eb
9866616
a18a1ed
89bc458
18a9037
e4dbd5d
5d6d471
77158d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,17 +16,21 @@ namespace ODataServiceSample.AspNetCore | |
using Microsoft.Extensions.DependencyInjection; | ||
using Moq; | ||
using NewPlatform.Flexberry; | ||
using NewPlatform.Flexberry.Caching; | ||
using NewPlatform.Flexberry.ORM.CurrentUserService; | ||
using NewPlatform.Flexberry.ORM.ODataService.Extensions; | ||
using NewPlatform.Flexberry.ORM.ODataService.Files; | ||
using NewPlatform.Flexberry.ORM.ODataService.Model; | ||
using NewPlatform.Flexberry.ORM.ODataService.Tests; | ||
using NewPlatform.Flexberry.ORM.ODataService.WebApi.Extensions; | ||
using NewPlatform.Flexberry.ORM.ODataServiceCore.Common.Exceptions; | ||
using NewPlatform.Flexberry.ORM.ODataServiceCore.Extensions; | ||
using NewPlatform.Flexberry.ORM.ODataServiceCore.Extensions; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В этом файле точно все добавленные юзинги нужны? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
using NewPlatform.Flexberry.Reports.ExportToExcel; | ||
using NewPlatform.Flexberry.Security; | ||
using NewPlatform.Flexberry.Services; | ||
using Unity; | ||
using Unity.Injection; | ||
using LockService = NewPlatform.Flexberry.Services.LockService; | ||
using LockService = NewPlatform.Flexberry.Services.LockService; | ||
|
||
public class Startup | ||
{ | ||
|
@@ -66,6 +70,56 @@ public virtual void ConfigureContainer(IUnityContainer unityContainer) | |
unityContainer.RegisterInstance(dataService); | ||
unityContainer.RegisterInstance<ILockService>(new LockService(dataService)); | ||
unityContainer.RegisterInstance<ISecurityManager>(new EmptySecurityManager()); | ||
|
||
unityContainer.RegisterType<IAuditService, AuditService>(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Посмотрела ORM. Там конструктору AuditService требуется ICurrentUser. Давай сразу это понятно пропишем по аналогии с MSSQLDataService. Думаю, нужно иные классы по аналогии перепроверить. |
||
unityContainer.RegisterSingleton<IExportService, ExportExcelODataService>("Export"); | ||
unityContainer.RegisterSingleton<IODataExportService, NewPlatform.Flexberry.ORM.ODataService.Tests.CRUD.Read.Excel.ExportExcel>(); | ||
unityContainer.RegisterSingleton<ISpreadsheetCustomizer, NewPlatform.Flexberry.ORM.ODataService.Tests.CRUD.Read.Excel.SpreadsheetCustomizer>(); | ||
unityContainer.RegisterSingleton<IConfigResolver, ConfigResolver>(); | ||
|
||
// ??? - без этого не давало в регистрацию MSSQLDataService ниже | ||
unityContainer.RegisterType<ICurrentUser, NewPlatform.Flexberry.ORM.ODataService.Tests.Http.WebHttpUser>(); | ||
|
||
unityContainer.RegisterSingleton<ICacheService, MemoryCacheService>( | ||
new InjectionConstructor("defaultCacheForApplication", 3600)); | ||
|
||
unityContainer.RegisterSingleton<ISecurityManager, EmptySecurityManager>("securityManagerWithoutRightsCheck"); | ||
|
||
unityContainer.RegisterSingleton<IDataService, MSSQLDataService>( | ||
"dataServiceForAuditAgentManagerAdapter", | ||
new InjectionConstructor( | ||
unityContainer.Resolve<ISecurityManager>("securityManagerWithoutRightsCheck"), | ||
unityContainer.Resolve<IAuditService>(), | ||
unityContainer.Resolve<IBusinessServerProvider>()), | ||
new InjectionProperty(nameof(MSSQLDataService.CustomizationStringName), "DefConnStr")); | ||
|
||
unityContainer.RegisterType<IDataService, MSSQLDataService>( | ||
"dataServiceForSecurityManager", | ||
new InjectionConstructor( | ||
unityContainer.Resolve<ISecurityManager>("securityManagerWithoutRightsCheck"), | ||
unityContainer.Resolve<IAuditService>(), | ||
unityContainer.Resolve<IBusinessServerProvider>()), | ||
Inject.Property(nameof(MSSQLDataService.CustomizationStringName), "DefConnStr")); | ||
|
||
unityContainer.RegisterSingleton<ICacheService, MemoryCacheService>( | ||
"cacheServiceForSecurityManager", | ||
new InjectionConstructor("cacheForSecurityManager")); | ||
|
||
unityContainer.RegisterSingleton<ICacheService, MemoryCacheService>( | ||
"cacheServiceForAgentManager", new InjectionConstructor("cacheForAgentManager")); | ||
|
||
// Параметры типа bool задаются по умолчанию в конструкторах | ||
unityContainer.RegisterSingleton<ISecurityManager, SecurityManager>( | ||
new InjectionConstructor( | ||
unityContainer.Resolve<IDataService>("dataServiceForSecurityManager"), | ||
unityContainer.Resolve<ICacheService>("cacheServiceForSecurityManager"))); | ||
|
||
unityContainer.RegisterSingleton<IAgentManager, AgentManager>( | ||
new InjectionConstructor( | ||
unityContainer.Resolve<IDataService>("dataServiceForSecurityManager"), | ||
unityContainer.Resolve<ICacheService>("cacheServiceForSecurityManager"))); | ||
|
||
unityContainer.RegisterSingleton<IPasswordHasher, Sha1PasswordHasher>(); | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to add services to the container. | ||
|
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.
Для чего здесь юзинги добавлены?
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.
Fixed