Exemple #1
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);
        }
Exemple #2
0
        private void EnsureImageExists(int maxDimension, string sourceFilePath, string destinationFilePath)
        {
            if (_diskInputOutputService.FileExists(destinationFilePath))
            {
                return;
            }

            lock (GetImageSyncRoot(destinationFilePath))
            {
                if (_diskInputOutputService.FileExists(destinationFilePath))
                {
                    return;
                }

                _diskInputOutputService.ResizeImage(maxDimension, sourceFilePath, destinationFilePath);
            }
        }
Exemple #3
0
        private Profile TryLoadProfile(string id)
        {
            string filePath = GetFilePath(id);

            if (!_diskInputOutputService.FileExists(filePath))
            {
                return(null);
            }

            var profile = _diskInputOutputService.LoadXmlFile <Profile>(filePath);

            _cacheService.SetProfile(profile, filePath);

            return(profile);
        }