예제 #1
0
        /// <summary>
        /// Request to delete data
        /// </summary>
        /// <param name="profileName">profile name</param>
        /// <param name="password">password</param>
        /// <param name="keys">key array</param>
        public void DeleteProfileValues(string profileName, byte[] password, string[] keys)
        {
            if (IsSupportPenProfile())
            {
                if (string.IsNullOrEmpty(profileName))
                {
                    throw new ArgumentNullException("profileName");
                }
                if (password == null)
                {
                    throw new ArgumentNullException("password");
                }
                if (keys == null)
                {
                    throw new ArgumentNullException("keys");
                }

                byte[] profileNameBytes = Encoding.UTF8.GetBytes(profileName);
                //byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
                if (profileNameBytes.Length > PenProfile.LIMIT_BYTE_LENGTH_PROFILE_NAME)
                {
                    new ArgumentOutOfRangeException("profileName", $"profileName byte length must be {PenProfile.LIMIT_BYTE_LENGTH_PROFILE_NAME} or less");
                }
                else if (password.Length != PenProfile.LIMIT_BYTE_LENGTH_PASSWORD)
                {
                    new ArgumentOutOfRangeException("password", $"password byte length must be {PenProfile.LIMIT_BYTE_LENGTH_PASSWORD}");
                }

                byte[][] keysBytes = new byte[keys.Length][];
                for (int i = 0; i < keys.Length; ++i)
                {
                    keysBytes[i] = Encoding.UTF8.GetBytes(keys[i]);
                    if (keysBytes[i].Length > PenProfile.LIMIT_BYTE_LENGTH_KEY)
                    {
                        throw new ArgumentOutOfRangeException("keys", $"key byte length must be {PenProfile.LIMIT_BYTE_LENGTH_KEY} or less");
                    }
                }

                Request(() => mClientV1.ReqDeleteProfileValue(profileNameBytes, password, keysBytes), () => mClientV2.ReqDeleteProfileValue(profileNameBytes, password, keysBytes));
            }
            else
            {
                throw new NotSupportedException($"CreateProfile is not supported at this pen firmware version");
            }
        }