Interface IDistributedContext
Provides queries and operations for Distributor-aware applications such as ICheckoutContext, Features
and Acquire()
.
Namespace: Sp.Agent.Distributor
Assembly: Sp.Agent.Distributor.dll
Properties
Checkout
Facilitates switching the application between Connected and Disconnected mode.
Declaration
ICheckoutContext Checkout { get; }
Property Value
Type | Description |
---|---|
ICheckoutContext |
Exceptions
Type | Condition |
---|---|
CheckoutRequiresStorageException | Thrown if no storage has been configured within the IAgentContext Configuration. |
Features
The set of Distributed Features held in this context, comprised of:
Leases or Checkouts that have expired are excluded from the results.
Declaration
ISet<string> Features { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ISet<System.String> |
Exceptions
Type | Condition |
---|---|
CheckoutStorageAccessException | Thrown if there is a problem accessing the Checkout storage mechanism. |
Methods
Acquire(Func<ISet<String>[], IEnumerable<String>>)
Manages the provisioning of features for the application based on the available Distributed resources (should a Distributor be configured).
The selector
function is responsible for choosing the set of features to be acquired as its return value. The chosen features must be contained within one of the supplied sets.
The sets provided represent either the currently available feature sets on the Distributor if Connected (or the checked out set if there is a TryGetCurrent(out ICheckout)).
Note selector
may be invoked multiple times (if an availability set has become unavailable by the time selector decides), until a successful selection occurs.
If no features are available, the selector
function will be passed a single empty set.
Declaration
void Acquire(Func<ISet<string>[], IEnumerable<string>> selector)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Collections.Generic.ISet<System.String>[], System.Collections.Generic.IEnumerable<System.String>> | selector | Responsible for selecting a subset of features to acquire given the sets available. |
Remarks
On success, Features will reflect the chosen features (any previously Acquired features are relinquished).
Note the recommended way to cancel the process is to yield an empty set from the selector
.
Any exception emitted from the supplied selector
function will be propagated.
Examples
// Acquire the biggest feature set available from the Distributor
// (assuming SKU design allocates most features to the 'best' licenses, this picks the most rich license)
SpAgent.Distributed.Acquire( sets => sets.OrderByDescending( setFeatures => setFeatures.Count() ).First() );
Exceptions
Type | Condition |
---|---|
DistributorRequestException | Thrown if there was an exception on the call to the Distributor. |
DistributorIntegrityException | Thrown if server integrity has been compromised. |
CheckoutStorageAccessException | Thrown if there is a problem accessing the store (if Checked out). |
System.InvalidOperationException | Thrown if |
Events
FeaturesUpdated
Triggered when the set of locally held features is updated for the ProductContextFor(String, String).
Declaration
event EventHandler<EventArgs> FeaturesUpdated
Event Type
Type | Description |
---|---|
System.EventHandler<System.EventArgs> |