1 //------------------------------------------------------------ 2 // Copyright (c) Microsoft Corporation. All rights reserved. 3 //------------------------------------------------------------ 4 5 namespace System.ServiceModel.Activities 6 { 7 using System.Runtime; 8 using System.ServiceModel; 9 using System.ServiceModel.Channels; 10 11 public class ChannelCacheSettings 12 { 13 TimeSpan idleTimeout; 14 TimeSpan leaseTimeout; 15 int maxItemsInCache; 16 17 internal static ChannelCacheSettings EmptyCacheSettings = new ChannelCacheSettings { MaxItemsInCache = 0 }; 18 ChannelCacheSettings()19 public ChannelCacheSettings() 20 { 21 this.idleTimeout = ChannelCacheDefaults.DefaultIdleTimeout; 22 this.leaseTimeout = ChannelCacheDefaults.DefaultLeaseTimeout; 23 this.maxItemsInCache = ChannelCacheDefaults.DefaultMaxItemsPerCache; 24 } 25 26 [Fx.Tag.KnownXamlExternal] 27 public TimeSpan IdleTimeout 28 { 29 get 30 { 31 return this.idleTimeout; 32 } 33 34 set 35 { 36 TimeoutHelper.ThrowIfNegativeArgument(value); 37 38 if (TimeoutHelper.IsTooLarge(value)) 39 { 40 throw FxTrace.Exception.ArgumentOutOfRange("IdleTimeout", value, SR.ValueTooLarge("IdleTimeout")); 41 } 42 43 this.idleTimeout = value; 44 } 45 } 46 47 [Fx.Tag.KnownXamlExternal] 48 public TimeSpan LeaseTimeout 49 { 50 get 51 { 52 return leaseTimeout; 53 } 54 set 55 { 56 TimeoutHelper.ThrowIfNegativeArgument(value); 57 58 if (TimeoutHelper.IsTooLarge(value)) 59 { 60 throw FxTrace.Exception.ArgumentOutOfRange("LeaseTimeout", value, SR.ValueTooLarge("LeaseTimeout")); 61 } 62 63 this.leaseTimeout = value; 64 } 65 } 66 67 public int MaxItemsInCache 68 { 69 get 70 { 71 return this.maxItemsInCache; 72 } 73 set 74 { 75 if (value < 0) 76 { 77 throw FxTrace.Exception.ArgumentOutOfRange("MaxItemsInCache", value, SR.ValueCannotBeNegative("MaxItemsInCache")); 78 } 79 80 this.maxItemsInCache = value; 81 } 82 } 83 } 84 } 85