コード例 #1
0
        public void Register(string name, string displayName)
        {
            if (!ApiScopeRepository.GetAll().Any(e => e.Name == name))
            {
                Permission scopeManagePermission = new Permission(name + ApiManageScope.NamePostfix)
                {
                    DisplayName = (displayName ?? name) + "域权限" + ApiManageScope.DisplayNamePostfix
                };
                _permissionManager.Create(scopeManagePermission);
                Permission queryManagePermission = new Permission(name + ApiQueryScope.NamePostfix)
                {
                    DisplayName = (displayName ?? name) + "域权限" + ApiQueryScope.DisplayNamePostfix
                };
                _permissionManager.Create(queryManagePermission);

                ApiScope apiScope = new ApiScope(name);

                apiScope.SetDisplayName(displayName ?? name);

                apiScope.ApiManageScope.AddPermission(scopeManagePermission);
                apiScope.ApiQueryScope.AddPermission(scopeManagePermission);
                apiScope.ApiQueryScope.AddPermission(queryManagePermission);

                ApiScopeRepository.Insert(apiScope);
            }
        }
コード例 #2
0
        public void Register(string name, string displayName)
        {
            if (!_apiScopeRepository.GetAll().Any(e => e.Name == name))
            {
                ApiScope apiScope = new ApiScope(name);

                apiScope.SetDisplayName(displayName ?? name);

                _apiScopeRepository.Insert(apiScope);
            }
        }
コード例 #3
0
        public void Register(string name, string displayName, List <Permission> managePermissions, List <Permission> queryPermissions)
        {
            if (!ApiScopeRepository.GetAll().Any(e => e.Name == name))
            {
                ApiScope apiScope = new ApiScope(name);

                apiScope.SetDisplayName(displayName ?? name);

                managePermissions.ForEach(item => apiScope.ApiManageScope.AddPermission(item));
                queryPermissions.ForEach(item => apiScope.ApiQueryScope.AddPermission(item));

                ApiScopeRepository.Insert(apiScope);
            }
        }