예제 #1
0
 /// <summary>
 /// Convert string to permission.
 /// </summary>
 /// <param name="permission">The permission string to convert.</param>
 /// <param name="testVersion">Test the OS version for support.</param>
 /// <returns>The converted permission.</returns>
 public static Permission ConvertStringToPermission(string permission, bool testVersion = true)
 {
     if (permissionToInfo.ContainsKey(permission))
     {
         var info = permissionToInfo[permission];
         if (!testVersion ||
             Util.IsCapableOfRunning(AvailableSinceAttribute.GetRequiredVersion(typeof(Permission).GetMember(info.Permission.ToString())[0]))) // If the OS supports it, then return it. Otherwise it will be unknown on that OS.
         {
             return(info.Permission);
         }
     }
     return(Permission.Unknown);
 }
예제 #2
0
 /// <summary>
 /// Throw an exception if the OS does not meet the required version for the member to execute.
 /// </summary>
 /// <param name="info">The member that wants to be used.</param>
 /// <param name="message">Any message to state about the exception.</param>
 public static void ThrowIfUnsupported(System.Reflection.MemberInfo info, string message = null)
 {
     ThrowIfUnsupported(AvailableSinceAttribute.GetRequiredVersion(info), message);
 }