netfx-System.AmbientSingleton 1.2.1

dotnet add package netfx-System.AmbientSingleton --version 1.2.1
NuGet\Install-Package netfx-System.AmbientSingleton -Version 1.2.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="netfx-System.AmbientSingleton" Version="1.2.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add netfx-System.AmbientSingleton --version 1.2.1
#r "nuget: netfx-System.AmbientSingleton, 1.2.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install netfx-System.AmbientSingleton as a Cake Addin
#addin nuget:?package=netfx-System.AmbientSingleton&version=1.2.1

// Install netfx-System.AmbientSingleton as a Cake Tool
#tool nuget:?package=netfx-System.AmbientSingleton&version=1.2.1

Provides an easy way to implement the singleton (anti?) pattern so that it is ambient-safe, propagates with a call context and can be overriden per ambient (i.e. in tests).

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on netfx-System.AmbientSingleton:

Package Downloads

Only two APIs are provided: the IAdapterService and its facade extension method As in the Adapters type. You can chose to use the former service directly instead of the convenience extension method. You don't lose any testability in doing either way, although you do need to pass around the adapter service in one case. ======= Example ======= // Calling code assumes there is a service always setup before invoking. // If there isn't, an InvalidOperationException is thrown automatically. // Use adapter extension method As as needed, i.e. // say we need to use it as an MSBuild project, if possible IMSBuildProject msbuild = project.As<IMSBuildProject>(); if (msbuild != null) // do MSBuild stuff with it.


The provided adapter pattern allows to convert any object to any other supported type, as provided by the registered adapters. This package provides the actual implementation of the service. It should only be added to the bootstrapping component of your application. ======= Example ======= IProject project = GetCurrentProject(); // say we need to use it as an MSBuild project, if possible IMSBuildProject msbuild = project.As<IMSBuildProject>(); if (msbuild != null) // do MSBuild stuff with it. ======= Adapters ======= public class ProjectToMsBuildAdapter : IAdapter<IProject, IMSBuildProject> { // Implement actual conversion. } The conversion behavior is now decoupled from the usage. Note that to create adapter implementations, you need to install the Adapter.Sdk package.


An IClock interface and default implementation SystemClock to make time-based logic testable.


Provides an the public API to perform general purpose adaptation of one type to another via registered adapters

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 2,382 1/21/2013
1.2.0 8,202 1/14/2013
1.1.0 9,523 12/3/2012
1.0.0 2,903 1/10/2012

           * Changed to use CallContext.SetData/GetData instead of forcing LogicalSetData/GetData.
           this allows the default behavior of only remoting across AppDomain/process boundaries
           the actual values that implement ILogicalThreadAffinative.