• Webservices API
  • Agent Runtime API
  • Support
  • Samples
  • Software Potential Home
Show / Hide Table of Contents
  • Sp.Agent
    • ActivateLicensesExtensions
    • IProductContext
    • ProductActivationConfigurationCompleteWithDefaultsExtensions
    • ProductActivationConfigurationDefaultExtensions
  • Sp.Agent.Activation
    • ActivationServerException
    • ActivationTransmissionException
    • DeviceChangedActivationServerException
    • DistributorLicenseActivationServerException
    • IActivateLicenses
    • IActivateLicensesAdvanced
    • InvalidLicenseKeyException
    • InvalidVersionActivationServerException
    • LicenseDisabledActivationServerException
    • LicenseExpiredActivationServerException
    • LinkedLicenseAmbiguousStorageActivationServerException
    • LinkedLicenseNoStorageActivationServerException
    • NumberOfActivationsExceededActivationServerException
    • ProductIdMismatchActivationServerException
    • RenewalNotAuthorizedActivationServerException
    • TagsChangedActivationServerException
  • Sp.Agent.Configuration
    • AgentContext
    • AgentContextDistributorsExtensions
    • AgentDistributorsConfigurationExtensions
    • CloudStorageConfigurationExtensions
    • ConfigurationCompleteWithDefaultsExtensions
    • CrmActivationEndpointsConfigurationPhaseExtensions
    • CrmAgentContextExtensions
    • CrmStartingConfigurationPhaseExtensions
    • DistributorDisableStorageExtensions
    • FileStoreInitialization
    • HardwareStoreConfigurationExtensions
    • HardwareStoreInitialization
    • IAgentChallengeConfigurationPhase
    • IAgentCloudStorageCommenceConfigurationPhase
    • IAgentCloudStorageCompleteConfigurationPhase
    • IAgentCloudStorageConfigurationPhase
    • IAgentCloudStorageConfigurationPhaseTail
    • IAgentCloudStorageCustomIdConfigurationPhase
    • IAgentCommenceConfigurationPhase
    • IAgentCompletedConfigurationPhase
    • IAgentContext
    • IAgentDistributorsConfigurationPhase
    • IAgentEmbeddedLicensesConfigurationPhase
    • IAgentExternalStorageConfigurationPhase
    • IAgentHardwareBoundStorageConfigurationPhase
    • IAgentUserBoundStorageConfigurationPhase
    • ICrmActivationEndpointsConfigurationPhase
    • IDistributorCommenceConfigurationPhase
    • IDistributorCompletedConfigurationPhase
    • IDistributorConfigurationPhaseTail
    • IDistributorNamedUserConfigurationPhase
    • IInitializeStores
    • IStoreLicensesInitializationExtensions
    • LocalStoreConfigurationExtensions
    • LocalStoreInitialization
    • ProductContextDistributedExtensions
    • RemovableConfigurationExtensions
    • WebApplicationStoreConfigurationExtensions
  • Sp.Agent.Configuration.Product
    • IProductCommenceConfigurationPhase
    • IProductCompletedConfigurationPhase
    • IProductConfigurationPhaseTail
  • Sp.Agent.Configuration.Product.Activation
    • IActivationAttemptContext
    • IActivationDeviceLabelContext
    • IActivationTaggingContext
    • IProductActivationCommenceConfigurationPhase
    • IProductActivationCompletedConfigurationPhase
    • IProductActivationConfigurationPhase
    • IProductActivationConfigurationPhaseTail
    • IProductActivationDeviceLabelConfigurationPhase
    • IProductActivationDeviceLabelTailConfigurationPhase
    • IProductActivationTransmissionCommenceConfigurationPhase
    • IProductActivationTransmissionCompletedConfigurationPhase
    • IProductActivationTransmissionConfigurationPhase
    • IProductActivationTransmissionConfigurationPhaseTail
    • IProductActivationTransmissionEndpointConfigurationPhase
    • IProductActivationTransmissionHooksConfigurationPhase
    • IProductActivationTransmissionProxyConfigurationPhase
    • ProductActivationConfigurationException
  • Sp.Agent.Distributor
    • CheckedOutNotLicensedException
    • CheckoutRequiresStorageException
    • CheckoutStorageAccessException
    • DistributorIntegrityException
    • DistributorIntegrityNotLicensedException
    • DistributorNotLicensedException
    • DistributorRequestException
    • IAvailableCheckout
    • ICheckout
    • ICheckoutContext
    • IDistributedContext
    • IDistributorsContext
    • NoDistributorException
    • NoLongerAvailableException
    • NotLicnesedInvalidNamedUserException
  • Sp.Agent.Execution
    • NotLicensedException
  • Sp.Agent.Licensing
    • IFeature
    • ILicense
    • ILicenseAdvanced
    • ILicensePeriod
    • ILicenseRenewal
    • IQueryFeatures
    • IQueryLicenses
    • IQueryLocalFeatures
    • IQueryUserTokens
    • IUserToken
    • LicenseRevisionException
  • Sp.Agent.Storage
    • DistributorLicenseOnClientException
    • InvalidStorageAccessException
    • InvalidStorageException
    • IStore
    • IStoreLicenses
    • IStoreUserTokens
    • LicenseNotFoundException
    • LicenseTargetEnvironmentMismatchException
    • NonmatchingProductIdException
    • ReadingStorageInaccessibleException
    • ServerOSNotAllowedException
    • StorageInaccessibleException
    • StoreNotEmptyException
    • UserTokenNotFoundException
    • VirtualMachineNotAllowedException
    • WritingStorageInaccessibleException

Class CrmAgentContextExtensions

Layers configuration extension methods onto IAgentContext appropriate to the Microsoft Dynamics CRM 2011 environment.

See EnsureConfigured(IAgentContext, Func<IAgentCommenceConfigurationPhase, IAgentCompletedConfigurationPhase>) for a usage example.

Namespace: Sp.Agent.Configuration
Assembly: Sp.Agent.Crm.dll

Methods

EnsureConfigured(IAgentContext, Func<IAgentCommenceConfigurationPhase, IAgentCompletedConfigurationPhase>)

Enables one to provide a Configuration Expression specifying the details appropriate to the execution and/or licensing of your Microsoft Dynamics CRM 2011 Component.

Declaration
public static void EnsureConfigured(this IAgentContext that, Func<IAgentCommenceConfigurationPhase, IAgentCompletedConfigurationPhase> compose)
Parameters
Type Name Description
IAgentContext that

IAgentContext to be configured. See For(String) for details of obtaining an instance.

System.Func<IAgentCommenceConfigurationPhase, IAgentCompletedConfigurationPhase> compose

IAgentCommenceConfigurationPhase for details of composing a Configuration Expression appropriate to your application style/environment using the fluent expression composition sequence.

Remarks

This method can be called any number of times; the implementation ensures that the underlying .Configure() method only gets triggered once.

Examples
             // NB an Assembly Reference to Sp.Agent.Crm.dll is required for this to work
            using Sp.Agent.Configuration; // AgentContext.For(string), IAgentContext.EnsureConfigured
            using Sp.Agent; // IProductContext
            using System; // IServiceProvider

            class SpAgent
            {
                static readonly IAgentContext _agentContext = AgentContext.For( "abc12" );
                static IProductContext _productContext;

                // Maintains a copy of the Dynamics CRM Service Context for the current processing thread. 
                // NB For this to work correctly, it is important that Sp.Agent Apis are only called from the same processing thread that invokes SpAgent.Initialize
                [ThreadStatic]
                static IServiceProvider _currentServiceProvider;

                // Provides access to Product-level information from the Software Potential Agent
                // Should not be accessed without first calling SpAgent.Initialize on the calling thread.
                public static IProductContext Product
                {
                    get
                    {
                        if ( _productContext == null )
                            _productContext = _agentContext.ProductContextFor( "My Plugin", "1.0" );
                        return _productContext;
                    }
                }

                // Should be called from your Plugin.cs IPlugin.Execute implementation, i.e., as follows:-
                //
                // public void Execute( IServiceProvider serviceProvider )
                // {
                //     SpAgent.Initialize(serviceProvider);
                //     // ... rest of method ....
                public static void Initialize( IServiceProvider serviceProvider )
                {
                    // Update thread-relative 
                    _currentServiceProvider = serviceProvider;

                   // Applies the configuration (if it has not already been applied for this AppDomain).
                   // NB the _currentServiceProvider reference below is triggered on the fly as the Sp.Agent components require it. See comment beside the field above.
                    _agentContext.EnsureConfigured( x => x
                        .WithCrmOnlineOrganizationStore( () => _currentServiceProvider, "new" )
                        .CompleteWithDefaults()
                    );
                }

                // Triggers an Online Activation from the Software Potential service of the license with the specified activationKey identifier.
                // Should not be accessed without first calling SpAgent.Initialize on the calling thread.
                public static void Activate( string activationKey )
                {
                    Product.Activation.OnlineActivate( activationKey );
                }
            }

See Also

IAgentContext
AgentContext
EnsureConfigured(IAgentContext, Func<IAgentCommenceConfigurationPhase, IAgentCompletedConfigurationPhase>)
Back to top Generated by DocFX