private event EventHandler<AgScoStateChangedEventArgs> _agScoStateChanged;
private Interop.Bluetooth.AgScoStateChangedCallback _agScoStateChangedCallback;
- private static readonly BluetoothAudioImpl _instance = new BluetoothAudioImpl();
+ private static readonly Lazy<BluetoothAudioImpl> _instance = new Lazy<BluetoothAudioImpl>(() =>
+ {
+ return new BluetoothAudioImpl();
+ });
private bool disposed = false;
internal event EventHandler<AudioConnectionStateChangedEventArgs> AudioConnectionStateChanged
{
get
{
- return _instance;
+ return _instance.Value;
}
}
private Interop.Bluetooth.TrackInfoChangedCallback _trackInfoChangedCallback;
private Interop.Bluetooth.AvrcpControlConnectionChangedCallback _connStateChangedCallback;
- private static BluetoothAvrcpControlImpl _instance = new BluetoothAvrcpControlImpl();
+ private static readonly Lazy<BluetoothAvrcpControlImpl> _instance = new Lazy<BluetoothAvrcpControlImpl>(() =>
+ {
+ return new BluetoothAvrcpControlImpl();
+ });
private bool disposed = false;
internal event EventHandler<AvrcpControlConnectionChangedEventArgs> ConnectionChanged;
{
get
{
- return _instance;
+ return _instance.Value;
}
}
if (ret != (int)BluetoothError.None)
{
Log.Error(Globals.LogTag, "Failed to initialize AVRCP Control, Error - " + (BluetoothError)ret);
+ BluetoothErrorFactory.ThrowBluetoothException(ret);
}
}
private Interop.Bluetooth.ShuffleModeChangedCallback _shuffleModeChangedCallback;
private Interop.Bluetooth.ScanModeChangedCallback _scanModeChangedCallback;
- private static BluetoothAvrcpImpl _instance = new BluetoothAvrcpImpl();
+ private static Lazy<BluetoothAvrcpImpl> _instance = new Lazy<BluetoothAvrcpImpl>(() =>
+ {
+ return new BluetoothAvrcpImpl();
+ });
private bool disposed = false;
internal event EventHandler<TargetConnectionStateChangedEventArgs> TargetConnectionStateChanged
{
get
{
- return _instance;
+ return _instance.Value;
}
}
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
+using System.Reflection;
namespace Tizen.Network.Bluetooth
{
/// <since_tizen> 3 </since_tizen>
public T GetProfile<T>() where T : BluetoothProfile
{
- // TODO : Need to check capability of supporting profiles
- var profile = (T)Activator.CreateInstance(typeof(T), true);
- profile.RemoteAddress = RemoteDeviceAddress;
- return profile;
+ try
+ {
+ // TODO : Need to check capability of supporting profiles
+ var profile = (T)Activator.CreateInstance(typeof(T), true);
+ profile.RemoteAddress = RemoteDeviceAddress;
+ return profile;
+ }
+ catch (TargetInvocationException err)
+ {
+ throw err.InnerException;
+ }
}
/// <summary>
private event EventHandler<HidDeviceDataReceivedEventArgs> _hidDeviceDataReceived;
private Interop.Bluetooth.HidDeviceDataReceivedCallback _hidDeviceDataReceivedCallback;
- private static readonly BluetoothHidDeviceImpl _instance = new BluetoothHidDeviceImpl();
+ private static readonly Lazy<BluetoothHidDeviceImpl> _instance = new Lazy<BluetoothHidDeviceImpl>(() =>
+ {
+ return new BluetoothHidDeviceImpl();
+ });
internal event EventHandler<HidDeviceConnectionStateChangedEventArgs> ConnectionStateChanged
{
{
get
{
- return _instance;
+ return _instance.Value;
}
}
private event EventHandler<HidConnectionStateChangedEventArgs> _hidConnectionChanged;
private Interop.Bluetooth.HidConnectionStateChangedCallback _hidConnectionChangedCallback;
- private static readonly BluetoothHidImpl _instance = new BluetoothHidImpl();
+ private static readonly Lazy<BluetoothHidImpl> _instance = new Lazy<BluetoothHidImpl>(() =>
+ {
+ return new BluetoothHidImpl();
+ });
private bool disposed = false;
internal event EventHandler<HidConnectionStateChangedEventArgs> HidConnectionStateChanged
{
get
{
- return _instance;
+ return _instance.Value;
}
}
private BluetoothHidImpl ()
{
internal class BluetoothOppServerImpl
{
- private static readonly BluetoothOppServerImpl _instance = new BluetoothOppServerImpl();
+ private static readonly Lazy<BluetoothOppServerImpl> _instance = new Lazy<BluetoothOppServerImpl>(() =>
+ {
+ return new BluetoothOppServerImpl();
+ });
internal event EventHandler<ConnectionRequestedEventArgs> ConnectionRequested;
private Interop.Bluetooth.ConnectionRequestedCallback _ConnectionRequestedCallback;
{
get
{
- return _instance;
+ return _instance.Value;
}
}
}
internal class BluetoothOppClientImpl
{
- private static readonly BluetoothOppClientImpl _instance = new BluetoothOppClientImpl();
+ private static readonly Lazy<BluetoothOppClientImpl> _instance = new Lazy<BluetoothOppClientImpl>(() =>
+ {
+ return new BluetoothOppClientImpl();
+ });
internal event EventHandler<PushRespondedEventArgs> PushResponded;
private Interop.Bluetooth.PushRespondedCallback _PushRespondedCallback;
{
get
{
- return _instance;
+ return _instance.Value;
}
}
}