예제 #1
0
        /// <summary>
        /// Transforms a SharePoint page uri
        /// </summary>
        /// <param name="pageTransformator">The page transformator to use</param>
        /// <param name="sourceContext">The source context</param>
        /// <param name="targetContext">The destination context</param>
        /// <param name="sourceUri">The source URI</param>
        /// <returns>The resulting URI</returns>
        public static Task <Uri> TransformSharePointAsync(this IPageTransformator pageTransformator, ClientContext sourceContext, PnPContext targetContext, Uri sourceUri)
        {
            if (pageTransformator == null)
            {
                throw new ArgumentNullException(nameof(pageTransformator));
            }
            if (sourceContext == null)
            {
                throw new ArgumentNullException(nameof(sourceContext));
            }
            if (targetContext == null)
            {
                throw new ArgumentNullException(nameof(targetContext));
            }
            if (sourceUri == null)
            {
                throw new ArgumentNullException(nameof(sourceUri));
            }

            var sourceItemId = new SharePointSourceItemId(sourceUri);

            var sourceProvider = new SharePointSourceProvider(sourceContext);

            return(pageTransformator.TransformAsync(new PageTransformationTask(sourceProvider, sourceItemId, targetContext)));
        }
        /// <summary>
        /// Creates a new transformation process for SharePoint and waits for its completion
        /// </summary>
        /// <param name="transformationExecutor">The executor to use</param>
        /// <param name="sourceContext">The source context</param>
        /// <param name="targetContext">The target context</param>
        /// <param name="token">The cancellation token, if any</param>
        /// <returns>The status of the transformation process</returns>
        public static Task <TransformationProcessStatus> TransformSharePointAsync(
            this ITransformationExecutor transformationExecutor,
            ClientContext sourceContext,
            PnPContext targetContext,
            CancellationToken token = default)
        {
            if (transformationExecutor == null)
            {
                throw new ArgumentNullException(nameof(transformationExecutor));
            }

            // Create the provider
            var sourceProvider = new SharePointSourceProvider(sourceContext);

            return(transformationExecutor.TransformAsync(sourceProvider, targetContext, token));
        }
        /// <summary>
        /// Creates a new transformation process for SharePoint
        /// </summary>
        /// <param name="transformationProcess">The process to use</param>
        /// <param name="sourceContext">The source context</param>
        /// <param name="targetContext">The target context</param>
        /// <param name="token">The cancellation token, if any</param>
        public static Task StartSharePointProcessAsync(
            this ITransformationProcess transformationProcess,
            ClientContext sourceContext,
            PnPContext targetContext,
            CancellationToken token = default)
        {
            if (transformationProcess == null)
            {
                throw new ArgumentNullException(nameof(transformationProcess));
            }

            // Create the provider
            var sourceProvider = new SharePointSourceProvider(sourceContext);

            return(transformationProcess.StartProcessAsync(sourceProvider, targetContext, token));
        }