1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
//----------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------------
namespace System.ServiceModel.Activities.Description
{
using System.Collections.ObjectModel;
using System.Globalization;
using System.Runtime;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
[Fx.Tag.XamlVisible(false)]
public class WorkflowIdleBehavior : IServiceBehavior
{
internal const string defaultTimeToPersistString = "Infinite";
internal static TimeSpan defaultTimeToPersist = TimeSpan.MaxValue;
internal const string defaultTimeToUnloadString = "00:01:00";
internal static TimeSpan defaultTimeToUnload = TimeSpan.Parse(defaultTimeToUnloadString, CultureInfo.InvariantCulture);
TimeSpan timeToPersist;
TimeSpan timeToUnload;
public WorkflowIdleBehavior()
{
this.timeToPersist = defaultTimeToPersist;
this.timeToUnload = defaultTimeToUnload;
}
public TimeSpan TimeToPersist
{
get { return this.timeToPersist; }
set
{
if (value < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ErrorTimeToPersistLessThanZero);
}
this.timeToPersist = value;
}
}
public TimeSpan TimeToUnload
{
get { return this.timeToUnload; }
set
{
if (value < TimeSpan.Zero)
{
throw FxTrace.Exception.ArgumentOutOfRange("value", value, SR.ErrorTimeToUnloadLessThanZero);
}
this.timeToUnload = value;
}
}
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
WorkflowServiceHost workflowServiceHost = serviceHostBase as WorkflowServiceHost;
if (workflowServiceHost != null)
{
workflowServiceHost.IdleTimeToPersist = this.TimeToPersist;
workflowServiceHost.IdleTimeToUnload = this.TimeToUnload;
}
}
public void Validate(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase)
{
if (serviceDescription == null)
{
throw FxTrace.Exception.ArgumentNull("serviceDescription");
}
if (serviceHostBase == null)
{
throw FxTrace.Exception.ArgumentNull("serviceHostBase");
}
}
}
}
|