public Context(
     StateOperationContext operationContext,
     IState target,
     IShouldProcess shouldProcess,
     IProgressReport progressReport,
     ProgressMap progressMap)
 {
     _OperationContext = operationContext;
     _Target           = target;
     _ShouldProcess    = shouldProcess;
     _ProgressReport   = progressReport;
     _ProgressMap      = progressMap;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="operationContext">a state operation context.</param>
 /// <param name="target">An Azure target state.</param>
 /// <param name="shouldProcess">A 'should process' interface</param>
 /// <param name="reportTaskProgress">A callback to report progress.</param>
 /// <param name="progressMap">Task progress information.</param>
 public Context(
     StateOperationContext operationContext,
     IState target,
     IShouldProcess shouldProcess,
     Action <ITaskProgress> reportTaskProgress,
     ProgressMap progressMap)
 {
     _OperationContext   = operationContext;
     _Target             = target;
     _ShouldProcess      = shouldProcess;
     _ReportTaskProgress = reportTaskProgress;
     _ProgressMap        = progressMap;
 }
        public static async Task <IState> UpdateStateAsync <TModel>(
            this ResourceConfig <TModel> config,
            IClient client,
            IState target,
            CancellationToken cancellationToken,
            IShouldProcess shouldProcess,
            IProgressReport progressReport)
            where TModel : class
        {
            var context = new Context(
                new StateOperationContext(client, cancellationToken),
                target,
                shouldProcess,
                progressReport,
                config.GetProgressMap(target));
            await context.UpdateStateAsync(config);

            return(context.Result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="config">A resource config.</param>
        /// <param name="client">Management client.</param>
        /// <param name="target">An Azure target state.</param>
        /// <param name="cancellationToken">A task cancellation token.</param>
        /// <param name="shouldProcess">A should process interface.</param>
        /// <param name="reportTaskProgress">A callback to report task progress.</param>
        /// <returns></returns>
        public static async Task <IState> UpdateStateAsync <TModel>(
            this ResourceConfig <TModel> config,
            IClient client,
            IState target,
            CancellationToken cancellationToken,
            IShouldProcess shouldProcess,
            Action <ITaskProgress> reportTaskProgress)
            where TModel : class
        {
            if (target.Get(config) == null)
            {
                return(new State());
            }
            var context = new Context(
                new StateOperationContext(client, cancellationToken),
                target,
                shouldProcess,
                reportTaskProgress,
                config.GetProgressMap(target));
            await context.UpdateStateAsync(config);

            return(context.Result);
        }