Esempio n. 1
0
        /// <summary>
        /// Tries to get a <see cref="CustomRole"/> by name.
        /// </summary>
        /// <param name="name">The name of the role to get.</param>
        /// <param name="customRole">The custom role.</param>
        /// <returns>True if the role exists.</returns>
        /// <exception cref="ArgumentNullException">If the name is a null or empty string.</exception>
        public static bool TryGet(string name, out CustomRole customRole)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            customRole = int.TryParse(name, out int id) ? Get(id) : Get(name);

            return(customRole != null);
        }
Esempio n. 2
0
        /// <summary>
        /// Tries to get a <see cref="CustomRole"/> by <inheritdoc cref="Id"/>.
        /// </summary>
        /// <param name="id">The ID of the role to get.</param>
        /// <param name="customRole">The custom role.</param>
        /// <returns>True if the role exists.</returns>
        public static bool TryGet(int id, out CustomRole customRole)
        {
            customRole = Get(id);

            return(customRole != null);
        }