コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BackOfficeRoleProvider"/> class.
        /// </summary>
        /// <param name="hiveManager">The hive manager.</param>
        public BackOfficeRoleProvider(Lazy <IHiveManager> hiveManager)
        {
            // Since this service is instantiated by ASP.NET using a parameterless constructor,
            // we need to use the dependencyresolver here. However, to avoid throwing exceptions
            // from the constructor itself in the event of a bad resolution attempt, we'll
            // resolve it on first access by using Lazy.

            _hiveManager = hiveManager ?? new Lazy <IHiveManager>(
                () => DependencyResolver.Current.GetService <IUmbracoApplicationContext>().Hive);

            _userHive =
                new Lazy <GroupUnitFactory <ISecurityStore> >(
                    () => Hive.GetWriter <ISecurityStore>(new Uri("security://users")));

            _userGroupHive =
                new Lazy <GroupUnitFactory <ISecurityStore> >(
                    () => Hive.GetWriter <ISecurityStore>(new Uri("security://user-groups")));
        }