This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lazy initialization to AdcController
- Add lazy initialization to I2cController. - Also changed DeviceCollection making it accessible as property. - Make sure that the variables do exist when being used. Using the previous code was causing issues because, on occasions, the related types could still be unresolved. - Add AdcControllerManager allowing multiple ADC controllers. - Decorate fields with DebuggerBrowsableState to hide them on debug session. Signed-off-by: José Simões <[email protected]>
- Loading branch information
1 parent
6a9b3ea
commit 2ccc244
Showing
4 changed files
with
120 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Copyright (c) 2018 The nanoFramework project contributors | ||
// See LICENSE file in the project root for full license information. | ||
// | ||
|
||
using System.Collections; | ||
|
||
namespace Windows.Devices.Adc | ||
{ | ||
internal sealed class AdcControllerManager | ||
{ | ||
private static readonly object _syncLock = new object(); | ||
|
||
// backing field for ControllersCollection | ||
// to store the controllers that are open | ||
private static Hashtable s_controllersCollection; | ||
|
||
/// <summary> | ||
/// <see cref="AdcController"/> collection. | ||
/// </summary> | ||
/// <remarks> | ||
/// This collection is for internal use only. | ||
/// </remarks> | ||
internal static Hashtable ControllersCollection | ||
{ | ||
get | ||
{ | ||
if (s_controllersCollection == null) | ||
{ | ||
lock (_syncLock) | ||
{ | ||
if (s_controllersCollection == null) | ||
{ | ||
s_controllersCollection = new Hashtable(); | ||
} | ||
} | ||
} | ||
|
||
return s_controllersCollection; | ||
} | ||
|
||
set | ||
{ | ||
s_controllersCollection = value; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters