Beispiel #1
0
        public void SetRole(Role role, string filePath)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role");
            }

            if (!Enum.IsDefined(typeof(RoleType), role.Type))
            {
                throw new ArgumentException("Role.Type is an undefined", "role");
            }

            if (filePath == null)
            {
                throw new ArgumentNullException("filePath");
            }

            _cache.Insert(CreateRoleKey(role.Type), role, new CacheDependency(filePath));
        }
Beispiel #2
0
        private Role LoadRole(RoleType roleType)
        {
            string fileName = Enum.GetName(typeof(RoleType), roleType) + ".xml";

            string filePath = Path.Combine(_rolesDirectoryPath, fileName);

            Role role;

            if (_diskInputOutputService.FileExists(filePath))
            {
                role = _diskInputOutputService.LoadXmlFile<Role>(filePath);
            }
            else
            {
                role = new Role
                           {
                               Ids = new List<string>(),
                               Type = roleType
                           };
            }

            _cacheService.SetRole(role, filePath);

            return role;
        }