1 //----------------------------------------------------------------------------- 2 // Copyright (c) Microsoft Corporation. All rights reserved. 3 //----------------------------------------------------------------------------- 4 5 namespace System.ServiceModel.Activities 6 { 7 8 using System; 9 using System.Activities.Statements; 10 using System.Activities; 11 using System.Collections.ObjectModel; 12 using System.Collections.Generic; 13 using System.Windows.Markup; 14 using System.ComponentModel; 15 16 [ContentProperty("Body")] 17 class MessagingNoPersistScope : NativeActivity 18 { 19 Variable<NoPersistHandle> noPersistHandle; 20 MessagingNoPersistScope()21 public MessagingNoPersistScope() 22 { 23 this.noPersistHandle = new Variable<NoPersistHandle>(); 24 } 25 26 [DefaultValue(null)] 27 public Activity Body 28 { 29 get; 30 set; 31 } 32 CacheMetadata(NativeActivityMetadata metadata)33 protected override void CacheMetadata(NativeActivityMetadata metadata) 34 { 35 metadata.AddChild(this.Body); 36 metadata.AddImplementationVariable(this.noPersistHandle); 37 } 38 Execute(NativeActivityContext context)39 protected override void Execute(NativeActivityContext context) 40 { 41 if (this.Body != null) 42 { 43 if (this.DisallowPersistence(context)) 44 { 45 NoPersistHandle handle = this.noPersistHandle.Get(context); 46 handle.Enter(context); 47 } 48 context.ScheduleActivity(this.Body); 49 } 50 } 51 DisallowPersistence(NativeActivityContext context)52 bool DisallowPersistence(NativeActivityContext context) 53 { 54 return context.GetExtension<SendReceiveExtension>() == null; 55 } 56 } 57 } 58