public void RenameProfile(string profileId, string newProfileId)
        {
            if (IsProfileReadOnly(profileId))
            {
                throw new ArgumentException("Cannot rename read-only profile", nameof(profileId));
            }

            if (newProfileId == ShortcutManager.defaultProfileId)
            {
                throw new ArgumentException("Duplicate profile id", nameof(newProfileId));
            }

            var profile = m_ShortcutProfileManager.GetProfileById(profileId);

            switch (m_ShortcutProfileManager.CanRenameProfile(profile, newProfileId))
            {
            case CanRenameProfileResult.Success:
                m_ShortcutProfileManager.RenameProfile(profile, newProfileId);
                break;

            case CanRenameProfileResult.InvalidProfileId:
                throw new ArgumentException("Profile not available", nameof(profileId));

            case CanRenameProfileResult.DuplicateProfileId:
                throw new ArgumentException("Duplicate profile id", nameof(newProfileId));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #2
0
        public bool CanRenameActiveProfile(string newProfileId)
        {
            if (m_ShortcutProfileManager.activeProfile == null)
            {
                return(false);
            }

            return(m_ShortcutProfileManager.CanRenameProfile(m_ShortcutProfileManager.activeProfile, newProfileId) == CanRenameProfileResult.Success);
        }