/// <summary>
        /// When implemented in a derived class, runs the activity’s execution logic.
        /// </summary>
        /// <param name="context">The execution context in which the activity executes.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            // Enter a no persist zone to pin this activity to memory since we are setting up a delegate to receive a callback
            var handle = this.noPersistHandle.Get(context);

            handle.Enter(context);

            // Get (which may create) the extension
            var extension = context.GetExtension <Hosting.FolderWatcherExtension>();

            string folder = context.GetValue(this.WatchFolder);

            if (!System.IO.Directory.Exists(folder))
            {
                throw new OperationCanceledException(String.Format("The path \"{0}\" is not a directory or does not exist.", folder));
            }

            // Set a bookmark - the extension will resume when the FileSystemWatcher is fired
            var bookmark = context.CreateBookmark(String.Format("FolderWatch_{0:N}", Guid.NewGuid()), FileWatcherBookmarkCallback);

            bookmarkWatcher.Set(context, bookmark);

            extension.RegisterListener(bookmark, folder, context.GetValue(this.WatchPattern), this.WatchSubfolders);
        }
示例#2
0
 public void Initialize(NativeActivityContext context, Guid scope)
 {
     this.ThrowIfContextIsNullOrDisposed(context);
     base.ThrowIfUninitialized();
     this.bookmarkScope.Initialize(context, scope);
 }
示例#3
0
 protected abstract void Execute(NativeActivityContext context);
示例#4
0
 public void CompleteTransaction(NativeActivityContext context)
 {
     CompleteTransactionCore(context, null);
 }
示例#5
0
 public void RequireTransactionContext(NativeActivityContext context, Action <NativeActivityTransactionContext, object> callback, object state)
 {
     RequestOrRequireTransactionContextCore(context, callback, state, true);
 }
示例#6
0
 //[SuppressMessage(FxCop.Category.Design, FxCop.Rule.ConsiderPassingBaseTypesAsParameters,
 //    Justification = "This method is designed to be called from activities with handle access.")]
 public Transaction GetCurrentTransaction(NativeActivityContext context)
 {
     return(GetCurrentTransactionCore(context));
 }