Example #1
0
		/// <summary>
		/// Request to get data from profile
		/// </summary>
		/// <param name="profileName">profile name</param>
		/// <param name="keys">key array</param>
		public void ReadProfileValues(string profileName, string[] keys)
		{
			if (IsSupportPenProfile())
			{
				if (string.IsNullOrEmpty(profileName))
					throw new ArgumentNullException("profileName");
				if (keys == null)
					throw new ArgumentNullException("keys");

				byte[] profileNameBytes = Encoding.UTF8.GetBytes(profileName);
				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");

				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.ReqReadProfileValue(profileNameBytes, keysBytes), () => mClientV2.ReqReadProfileValue(profileNameBytes, keysBytes));
			}
			else
				throw new NotSupportedException($"CreateProfile is not supported at this pen firmware version");
		}