/// <summary>
        /// Checks whether a <see cref="DefaultCapability"/> is already used by the user.
        /// </summary>
        /// <typeparam name="T">The specific kind of <see cref="AccessPoints.DefaultAccessPoint"/> to handle.</typeparam>
        /// <param name="toCheck">The <see cref="Capability"/> to check for usage.</param>
        /// <returns><see langword="true"/>, if <paramref name="toCheck"/> is already in usage.</returns>
        private bool IsCapabillityUsed <T>(DefaultCapability toCheck)
            where T : AccessPoints.DefaultAccessPoint
        {
            if (AppEntry.AccessPoints == null)
            {
                return(false);
            }

            return(AppEntry.AccessPoints.Entries.OfType <T>().Any(accessPoint => accessPoint.Capability == toCheck.ID));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="capability">That shall be wrapped.</param>
        /// <param name="used">Indicates whether the <see cref="Capability" /> was already used.</param>
        protected CapabilityModel([NotNull] DefaultCapability capability, bool used)
        {
            #region Sanity Checks
            if (capability == null)
            {
                throw new ArgumentNullException(nameof(capability));
            }
            #endregion

            Capability = capability;
            _wasUsed   = Use = used;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a <see cref="DefaultAccessPoint"/> referencing a specific <see cref="DefaultCapability"/>.
 /// </summary>
 /// <param name="capability">The <see cref="DefaultCapability"/> to create a <see cref="DefaultAccessPoint"/> for.</param>
 /// <returns>The newly created <see cref="DefaultAccessPoint"/>.</returns>
 public static AccessPoint ToAccessPoint(this DefaultCapability capability)
 => (capability ?? throw new ArgumentNullException(nameof(capability))) switch
Exemplo n.º 4
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="capability">That shall be wrapped.</param>
 /// <param name="used">Indicates whether the <see cref="Capability" /> was already used.</param>
 protected CapabilityModel(DefaultCapability capability, bool used)
 {
     Capability = capability ?? throw new ArgumentNullException(nameof(capability));
     _wasUsed   = Use = used;
 }