Skip to content

Commit

Permalink
Merge pull request #9 from ShawnLaMountain/main
Browse files Browse the repository at this point in the history
Updating Samples to use ThunderDesign.Net-PCL.Threading to version 1.0.10
  • Loading branch information
ShawnLaMountain authored Oct 30, 2023
2 parents 894dcea + 21380be commit fccee97
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static ContactsBridge Instance
{
get
{
lock (_Locker)
lock (_InstanceLocker)
{
return _Instance ??= new ContactsBridge();
}
Expand All @@ -26,7 +26,7 @@ public static ContactsBridge Instance
#endregion

#region variables
protected readonly static object _Locker = new();
private readonly static object _InstanceLocker = new object();
private static ContactsBridge? _Instance = null;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static SimpleContactsConnection Instance
{
get
{
lock (_Locker)
lock (_InstanceLocker)
{
return _Instance ??= new SimpleContactsConnection();
}
Expand All @@ -24,6 +24,7 @@ public static SimpleContactsConnection Instance
#endregion

#region variables
private readonly static object _InstanceLocker = new object();
private const string _DatabaseFilename = "Contacts.db3";
private static SimpleContactsConnection? _Instance = null;
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static ContactsTable Instance
{
get
{
lock (_Locker)
lock (_InstanceLocker)
{
return _Instance ??= new ContactsTable();
}
Expand All @@ -26,6 +26,7 @@ public static ContactsTable Instance
#endregion

#region variables
private readonly static object _InstanceLocker = new object();
private static ContactsTable? _Instance = null;
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static ContactsBridge Instance
{
get
{
lock (_Locker)
lock (_InstanceLocker)
{
return _Instance ??= new ContactsBridge();
}
Expand All @@ -26,7 +26,7 @@ public static ContactsBridge Instance
#endregion

#region variables
protected readonly static object _Locker = new object();
private readonly static object _InstanceLocker = new object();
private static ContactsBridge _Instance = null;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
using ThunderDesign.Net.SQLite.Connections;
using System;
using System.IO;
using ThunderDesign.Net.SQLite.Connections;
using Xamarin.Forms;

namespace SimpleContacts.Database.Connections
{
public class SimpleContactsConnection : BaseSQLiteConnection
{
#region constructors
public SimpleContactsConnection() : base(_DatabaseFilename)
public SimpleContactsConnection() : base(_DatabaseFilename, GetDatabasePath())
{
}
#endregion

#region properties
private static string GetDatabasePath()
{
string databasePath = "";
if (Device.RuntimePlatform == Device.iOS)
{
// we need to put in /Library/ on iOS5.1+ to meet Apple's iCloud terms
// (they don't want non-user-generated data in Documents)
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Documents folder
databasePath = Path.Combine(documentsPath, "..", "Library"); // Library folder instead
}
else if (Device.RuntimePlatform == Device.Android)
{
// Just use whatever directory SpecialPolder.Personal returns
databasePath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
}
return databasePath;
}

public static SimpleContactsConnection Instance
{
get
{
lock (_Locker)
lock (_InstanceLocker)
{
return _Instance ??= new SimpleContactsConnection();
}
Expand All @@ -24,6 +45,7 @@ public static SimpleContactsConnection Instance
#endregion

#region variables
private readonly static object _InstanceLocker = new object();
private const string _DatabaseFilename = "Contacts.db3";
private static SimpleContactsConnection _Instance = null;
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static ContactsTable Instance
{
get
{
lock (_Locker)
lock (_InstanceLocker)
{
return _Instance ??= new ContactsTable();
}
Expand All @@ -26,6 +26,7 @@ public static ContactsTable Instance
#endregion

#region variables
private readonly static object _InstanceLocker = new object();
private static ContactsTable _Instance = null;
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<ItemGroup>
<PackageReference Include="Sharpnado.Shadows" Version="1.2.0" />
<PackageReference Include="ThunderDesign.Net-PCL.Threading" Version="1.0.10" />
<PackageReference Include="ThunderDesign.Xamarin.Forms.FloatingActionButton" Version="1.0.0" />
<PackageReference Include="Xamarin.CommunityToolkit" Version="2.0.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.2337" />
Expand Down

0 comments on commit fccee97

Please sign in to comment.