Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
Change-Id: Ic7a2a54363f6928051479e6d2656e9a9e9cfc708
Name: csapi-network-nfc
Summary: Tizen Nfc API for C#
Name: csapi-network-nfc
Summary: Tizen Nfc API for C#
Release: 1
Group: Development/Libraries
License: Apache-2.0
Release: 1
Group: Development/Libraries
License: Apache-2.0
/// </summary>
public class NfcTagInformation
{
/// </summary>
public class NfcTagInformation
{
- internal NfcTagInformation()
- {
+ private string _key;
+ private byte[] _informationValue;
+ internal NfcTagInformation(string key, byte[] informationValue)
+ {
+ _key = key;
+ _informationValue = informationValue;
/// <summary>
/// Key value.
/// </summary>
/// <summary>
/// Key value.
/// </summary>
+ public string Key
+ {
+ get
+ {
+ return _key;
+ }
+ }
/// <summary>
/// Information value.
/// </summary>
/// <summary>
/// Information value.
/// </summary>
- public byte[] InformationValue;
+ public byte[] InformationValue
+ {
+ get
+ {
+ return _informationValue;
+ }
+ }
/// </summary>
public class NfcRegisteredAidInformation
{
/// </summary>
public class NfcRegisteredAidInformation
{
- internal NfcRegisteredAidInformation()
- {
+ private NfcSecureElementType _seType;
+ private string _aid;
+ private bool _readOnly;
+ internal NfcRegisteredAidInformation(NfcSecureElementType seType, string aid, bool readOnly)
+ {
+ _seType = seType;
+ _aid = aid;
+ _readOnly = readOnly;
/// <summary>
/// Secure Element Type value.
/// </summary>
/// <summary>
/// Secure Element Type value.
/// </summary>
- public NfcSecureElementType SeType;
+ public NfcSecureElementType SeType
+ {
+ get
+ {
+ return _seType;
+ }
+ }
+
+ ///
+ /// The targeted Aid (Application Identifier) value.
+ public string Aid
+ {
+ get
+ {
+ return _aid;
+ }
+ }
+
+ /// Read-only value. If this value is false, there are restrictions to the operation on this Aid.
+ public bool ReadOnly
+ {
+ get
+ {
+ return _readOnly;
+ }
+ }
{
if (aid != IntPtr.Zero)
{
{
if (aid != IntPtr.Zero)
{
- NfcRegisteredAidInformation aidInfo = new NfcRegisteredAidInformation();
-
- aidInfo.SeType = (NfcSecureElementType)type;
- aidInfo.Aid = Marshal.PtrToStringAnsi(aid);
- aidInfo.ReadOnly = readOnly;
+ NfcRegisteredAidInformation aidInfo = new NfcRegisteredAidInformation((NfcSecureElementType)type, Marshal.PtrToStringAnsi(aid), readOnly);
+ throw new NotSupportedException();
}
try
{
return NfcManagerImpl.Instance.IsSupported;
}
}
try
{
return NfcManagerImpl.Instance.IsSupported;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
+ throw new NotSupportedException();
}
try
{
return NfcManagerImpl.Instance.IsActivated;
}
}
try
{
return NfcManagerImpl.Instance.IsActivated;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
if (!isNfcSupported || !isTagSupported)
{
if (!isNfcSupported || !isTagSupported)
{
- return NfcTagFilterType.AllDisable;
+ throw new NotSupportedException();
}
try
{
return NfcManagerImpl.Instance.TagFilterType;
}
}
try
{
return NfcManagerImpl.Instance.TagFilterType;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
- return NfcTagFilterType.AllDisable;
+ throw e.InnerException;
if (!isNfcSupported || !isTagSupported)
{
if (!isNfcSupported || !isTagSupported)
{
+ throw new NotSupportedException();
}
try
{
NfcManagerImpl.Instance.TagFilterType = value;
}
}
try
{
NfcManagerImpl.Instance.TagFilterType = value;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
if (!isNfcSupported || !isCeSupported)
{
if (!isNfcSupported || !isCeSupported)
{
- return NfcSecureElementType.Disable;
+ throw new NotSupportedException();
}
try
{
return NfcManagerImpl.Instance.SecureElementType;
}
}
try
{
return NfcManagerImpl.Instance.SecureElementType;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
- return NfcSecureElementType.Disable;
+ throw e.InnerException;
+ bool isNfcSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc", out isNfcSupported);
+ bool isCeSupported = SystemInfo.TryGetValue("http://tizen.org/feature/network.nfc.cardemulation", out isCeSupported);
+
+ if (!isNfcSupported || !isCeSupported)
+ {
+ throw new NotSupportedException();
+ }
+
try
{
NfcManagerImpl.Instance.SecureElementType = value;
}
try
{
NfcManagerImpl.Instance.SecureElementType = value;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
+ throw new NotSupportedException();
}
try
{
return NfcManagerImpl.Instance.SystemHandlerEnabled;
}
}
try
{
return NfcManagerImpl.Instance.SystemHandlerEnabled;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
+ throw new NotSupportedException();
}
try
{
NfcManagerImpl.Instance.SystemHandlerEnabled = value;
}
}
try
{
NfcManagerImpl.Instance.SystemHandlerEnabled = value;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
+ throw new NotSupportedException();
}
try
{
return NfcManagerImpl.Instance.CachedNdefMessage;
}
}
try
{
return NfcManagerImpl.Instance.CachedNdefMessage;
}
- catch (TypeInitializationException)
+ catch (TypeInitializationException e)
+ throw e.InnerException;
{
if (key != IntPtr.Zero && infoValue != IntPtr.Zero)
{
{
if (key != IntPtr.Zero && infoValue != IntPtr.Zero)
{
- NfcTagInformation tagInfo = new NfcTagInformation();
+ NfcTagInformation tagInfo = new NfcTagInformation(Marshal.PtrToStringAnsi(key), new byte[valueSize]);
- tagInfo.Key = Marshal.PtrToStringAnsi(key);
- tagInfo.InformationValue = new byte[valueSize];
Marshal.Copy(infoValue, tagInfo.InformationValue, 0, valueSize);
infoList.Add(tagInfo);
Marshal.Copy(infoValue, tagInfo.InformationValue, 0, valueSize);
infoList.Add(tagInfo);