예제 #1
0
 /// <summary>
 /// public ctor - will generally just be used for unit testing
 /// </summary>
 /// <param name="contentService"></param>
 /// <param name="mediaService"></param>
 /// <param name="contentTypeService"></param>
 /// <param name="dataTypeService"></param>
 /// <param name="fileService"></param>
 /// <param name="localizationService"></param>
 /// <param name="packagingService"></param>
 /// <param name="entityService"></param>
 /// <param name="relationService"></param>
 /// <param name="sectionService"></param>
 /// <param name="treeService"></param>
 /// <param name="tagService"></param>
 public ServiceContext(
     IContentService contentService, 
     IMediaService mediaService, 
     IContentTypeService contentTypeService, 
     IDataTypeService dataTypeService, 
     IFileService fileService, 
     ILocalizationService localizationService, 
     PackagingService packagingService, 
     IEntityService entityService,
     IRelationService relationService,
     ISectionService sectionService,
     IApplicationTreeService treeService,
     ITagService tagService)
 {
     _tagService = new Lazy<ITagService>(() => tagService);     
     _contentService = new Lazy<IContentService>(() => contentService);        
     _mediaService = new Lazy<IMediaService>(() => mediaService);
     _contentTypeService = new Lazy<IContentTypeService>(() => contentTypeService);
     _dataTypeService = new Lazy<IDataTypeService>(() => dataTypeService);
     _fileService = new Lazy<IFileService>(() => fileService);
     _localizationService = new Lazy<ILocalizationService>(() => localizationService);
     _packagingService = new Lazy<PackagingService>(() => packagingService);
     _entityService = new Lazy<IEntityService>(() => entityService);
     _relationService = new Lazy<IRelationService>(() => relationService);
     _sectionService = new Lazy<ISectionService>(() => sectionService);
     _treeService = new Lazy<IApplicationTreeService>(() => treeService);
 }
예제 #2
0
        /// <summary>
        /// Creates a partial service context with only some services (for tests).
        /// </summary>
        /// <remarks>
        /// <para>Using a true constructor for this confuses DI containers.</para>
        /// </remarks>
        public static ServiceContext CreatePartial(
            IContentService contentService         = null,
            IMediaService mediaService             = null,
            IContentTypeService contentTypeService = null,
            IMediaTypeService mediaTypeService     = null,
            IDataTypeService dataTypeService       = null,
            IFileService fileService = null,
            ILocalizationService localizationService = null,
            IPackagingService packagingService       = null,
            IEntityService entityService             = null,
            IRelationService relationService         = null,
            IMemberGroupService memberGroupService   = null,
            IMemberTypeService memberTypeService     = null,
            IMemberService memberService             = null,
            IUserService userService            = null,
            ISectionService sectionService      = null,
            IApplicationTreeService treeService = null,
            ITagService tagService = null,
            INotificationService notificationService   = null,
            ILocalizedTextService localizedTextService = null,
            IAuditService auditService                           = null,
            IDomainService domainService                         = null,
            IMacroService macroService                           = null,
            IPublicAccessService publicAccessService             = null,
            IExternalLoginService externalLoginService           = null,
            IServerRegistrationService serverRegistrationService = null,
            IRedirectUrlService redirectUrlService               = null,
            IConsentService consentService                       = null)
        {
            Lazy <T> Lazy <T>(T service) => service == null ? null : new Lazy <T>(() => service);

            return(new ServiceContext(
                       Lazy(publicAccessService),
                       Lazy(domainService),
                       Lazy(auditService),
                       Lazy(localizedTextService),
                       Lazy(tagService),
                       Lazy(contentService),
                       Lazy(userService),
                       Lazy(memberService),
                       Lazy(mediaService),
                       Lazy(contentTypeService),
                       Lazy(mediaTypeService),
                       Lazy(dataTypeService),
                       Lazy(fileService),
                       Lazy(localizationService),
                       Lazy(packagingService),
                       Lazy(serverRegistrationService),
                       Lazy(entityService),
                       Lazy(relationService),
                       Lazy(treeService),
                       Lazy(sectionService),
                       Lazy(macroService),
                       Lazy(memberTypeService),
                       Lazy(memberGroupService),
                       Lazy(notificationService),
                       Lazy(externalLoginService),
                       Lazy(redirectUrlService),
                       Lazy(consentService)));
        }
예제 #3
0
 public SectionService(
     IUserService userService,
     IApplicationTreeService applicationTreeService,
     IScopeProvider scopeProvider,
     CacheHelper cache)
 {
     _applicationTreeService = applicationTreeService ?? throw new ArgumentNullException(nameof(applicationTreeService));
     _cache                = cache ?? throw new ArgumentNullException(nameof(cache));
     _userService          = userService;
     _scopeProvider        = scopeProvider;
     _allAvailableSections = new Lazy <IEnumerable <Section> >(() => new LazyEnumerableSections());
 }
예제 #4
0
        public SectionService(
            IUserService userService,
            IApplicationTreeService applicationTreeService, 
            CacheHelper cache)
        {
            if (applicationTreeService == null) throw new ArgumentNullException("applicationTreeService");
            if (cache == null) throw new ArgumentNullException("cache");

            _userService = userService;
            _applicationTreeService = applicationTreeService;
            _cache = cache;
        }
        /// <summary>
        /// This is used by any legacy services that require rendering a BaseTree, if a new controller tree is detected it will try to invoke it's legacy predecessor.
        /// </summary>
        /// <param name="appTreeService"></param>
        /// <param name="treeType"></param>
        /// <returns></returns>
        internal static BaseTree GetLegacyTreeForLegacyServices(IApplicationTreeService appTreeService, string treeType)
        {
            if (appTreeService == null) throw new ArgumentNullException("appTreeService");
            if (treeType == null) throw new ArgumentNullException("treeType");

            //first get the app tree definition so we can then figure out if we need to load by legacy or new
            //now we'll look up that tree
            var appTree = appTreeService.GetByAlias(treeType);
            if (appTree == null)
                throw new InvalidOperationException("No tree found with alias " + treeType);

            return GetLegacyTreeForLegacyServices(appTree);
        }
        private Dictionary <string, SearchableApplicationTree> CreateDictionary(IApplicationTreeService treeService)
        {
            var appTrees = treeService.GetAll()
                           .OrderBy(x => x.SortOrder)
                           .ToArray();
            var dictionary      = new Dictionary <string, SearchableApplicationTree>(StringComparer.OrdinalIgnoreCase);
            var searchableTrees = this.ToArray();

            foreach (var appTree in appTrees)
            {
                var found = searchableTrees.FirstOrDefault(x => x.TreeAlias.InvariantEquals(appTree.Alias));
                if (found != null)
                {
                    dictionary[found.TreeAlias] = new SearchableApplicationTree(appTree.ApplicationAlias, appTree.Alias, found);
                }
            }
            return(dictionary);
        }
예제 #7
0
        public SectionService(
            IUserService userService,
            IApplicationTreeService applicationTreeService,
            IDatabaseUnitOfWorkProvider uowProvider,
            CacheHelper cache)
        {
            if (applicationTreeService == null)
            {
                throw new ArgumentNullException("applicationTreeService");
            }
            if (cache == null)
            {
                throw new ArgumentNullException("cache");
            }

            _userService            = userService;
            _applicationTreeService = applicationTreeService;
            _uowProvider            = uowProvider;
            _cache = cache;
        }
        /// <summary>
        /// This is used by any legacy services that require rendering a BaseTree, if a new controller tree is detected it will try to invoke it's legacy predecessor.
        /// </summary>
        /// <param name="appTreeService"></param>
        /// <param name="treeType"></param>
        /// <returns></returns>
        internal static BaseTree GetLegacyTreeForLegacyServices(IApplicationTreeService appTreeService, string treeType)
        {
            if (appTreeService == null)
            {
                throw new ArgumentNullException("appTreeService");
            }
            if (treeType == null)
            {
                throw new ArgumentNullException("treeType");
            }

            //first get the app tree definition so we can then figure out if we need to load by legacy or new
            //now we'll look up that tree
            var appTree = appTreeService.GetByAlias(treeType);

            if (appTree == null)
            {
                throw new InvalidOperationException("No tree found with alias " + treeType);
            }

            return(GetLegacyTreeForLegacyServices(appTree));
        }
예제 #9
0
 /// <summary>
 /// public ctor - will generally just be used for unit testing all items are optional and if not specified, the defaults will be used
 /// </summary>
 /// <param name="contentService"></param>
 /// <param name="mediaService"></param>
 /// <param name="contentTypeService"></param>
 /// <param name="dataTypeService"></param>
 /// <param name="fileService"></param>
 /// <param name="localizationService"></param>
 /// <param name="packagingService"></param>
 /// <param name="entityService"></param>
 /// <param name="relationService"></param>
 /// <param name="memberGroupService"></param>
 /// <param name="memberTypeService"></param>
 /// <param name="memberService"></param>
 /// <param name="userService"></param>
 /// <param name="sectionService"></param>
 /// <param name="treeService"></param>
 /// <param name="tagService"></param>
 /// <param name="notificationService"></param>
 /// <param name="localizedTextService"></param>
 /// <param name="auditService"></param>
 /// <param name="domainService"></param>
 /// <param name="taskService"></param>
 /// <param name="macroService"></param>
 /// <param name="publicAccessService"></param>
 /// <param name="externalLoginService"></param>
 /// <param name="migrationEntryService"></param>
 public ServiceContext(
     IContentService contentService         = null,
     IMediaService mediaService             = null,
     IContentTypeService contentTypeService = null,
     IDataTypeService dataTypeService       = null,
     IFileService fileService = null,
     ILocalizationService localizationService = null,
     IPackagingService packagingService       = null,
     IEntityService entityService             = null,
     IRelationService relationService         = null,
     IMemberGroupService memberGroupService   = null,
     IMemberTypeService memberTypeService     = null,
     IMemberService memberService             = null,
     IUserService userService            = null,
     ISectionService sectionService      = null,
     IApplicationTreeService treeService = null,
     ITagService tagService = null,
     INotificationService notificationService   = null,
     ILocalizedTextService localizedTextService = null,
     IAuditService auditService                   = null,
     IDomainService domainService                 = null,
     ITaskService taskService                     = null,
     IMacroService macroService                   = null,
     IPublicAccessService publicAccessService     = null,
     IExternalLoginService externalLoginService   = null,
     IMigrationEntryService migrationEntryService = null)
 {
     if (migrationEntryService != null)
     {
         _migrationEntryService = new Lazy <IMigrationEntryService>(() => migrationEntryService);
     }
     if (externalLoginService != null)
     {
         _externalLoginService = new Lazy <IExternalLoginService>(() => externalLoginService);
     }
     if (auditService != null)
     {
         _auditService = new Lazy <IAuditService>(() => auditService);
     }
     if (localizedTextService != null)
     {
         _localizedTextService = new Lazy <ILocalizedTextService>(() => localizedTextService);
     }
     if (tagService != null)
     {
         _tagService = new Lazy <ITagService>(() => tagService);
     }
     if (contentService != null)
     {
         _contentService = new Lazy <IContentService>(() => contentService);
     }
     if (mediaService != null)
     {
         _mediaService = new Lazy <IMediaService>(() => mediaService);
     }
     if (contentTypeService != null)
     {
         _contentTypeService = new Lazy <IContentTypeService>(() => contentTypeService);
     }
     if (dataTypeService != null)
     {
         _dataTypeService = new Lazy <IDataTypeService>(() => dataTypeService);
     }
     if (fileService != null)
     {
         _fileService = new Lazy <IFileService>(() => fileService);
     }
     if (localizationService != null)
     {
         _localizationService = new Lazy <ILocalizationService>(() => localizationService);
     }
     if (packagingService != null)
     {
         _packagingService = new Lazy <IPackagingService>(() => packagingService);
     }
     if (entityService != null)
     {
         _entityService = new Lazy <IEntityService>(() => entityService);
     }
     if (relationService != null)
     {
         _relationService = new Lazy <IRelationService>(() => relationService);
     }
     if (sectionService != null)
     {
         _sectionService = new Lazy <ISectionService>(() => sectionService);
     }
     if (memberGroupService != null)
     {
         _memberGroupService = new Lazy <IMemberGroupService>(() => memberGroupService);
     }
     if (memberTypeService != null)
     {
         _memberTypeService = new Lazy <IMemberTypeService>(() => memberTypeService);
     }
     if (treeService != null)
     {
         _treeService = new Lazy <IApplicationTreeService>(() => treeService);
     }
     if (memberService != null)
     {
         _memberService = new Lazy <IMemberService>(() => memberService);
     }
     if (userService != null)
     {
         _userService = new Lazy <IUserService>(() => userService);
     }
     if (notificationService != null)
     {
         _notificationService = new Lazy <INotificationService>(() => notificationService);
     }
     if (domainService != null)
     {
         _domainService = new Lazy <IDomainService>(() => domainService);
     }
     if (taskService != null)
     {
         _taskService = new Lazy <ITaskService>(() => taskService);
     }
     if (macroService != null)
     {
         _macroService = new Lazy <IMacroService>(() => macroService);
     }
     if (publicAccessService != null)
     {
         _publicAccessService = new Lazy <IPublicAccessService>(() => publicAccessService);
     }
 }
예제 #10
0
 public SearchableTreeResolver(IServiceProvider serviceProvider, ILogger logger, IApplicationTreeService treeService, Func <IEnumerable <Type> > searchableTrees)
     : base(serviceProvider, logger, searchableTrees, ObjectLifetimeScope.HttpRequest)
 {
     _treeService = treeService;
 }
예제 #11
0
 internal UmbracoUiHelper(ISectionService sectionService,
                          IApplicationTreeService treeService)
 {
     _sectionService = sectionService;
     _treeService    = treeService;
 }
 public SearchableTreeCollection(IEnumerable <ISearchableTree> items, IApplicationTreeService treeService)
     : base(items)
 {
     _dictionary = CreateDictionary(treeService);
 }