/
ReliableSession.cs
74 lines (62 loc) · 2.63 KB
/
ReliableSession.cs
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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.ServiceModel.Channels;
namespace System.ServiceModel
{
// The only purpose in life for these classes is so that, on standard bindings, you can say
// binding.ReliableSession.Ordered
// binding.ReliableSession.InactivityTimeout
// binding.ReliableSession.Enabled
// where these properties are "bucketized" all under .ReliableSession, which makes them easier to
// discover/Intellisense
public class ReliableSession
{
ReliableSessionBindingElement _element;
public ReliableSession()
{
_element = new ReliableSessionBindingElement();
}
public ReliableSession(ReliableSessionBindingElement reliableSessionBindingElement)
{
if (reliableSessionBindingElement == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(reliableSessionBindingElement));
_element = reliableSessionBindingElement;
}
[DefaultValue(ReliableSessionDefaults.Ordered)]
public bool Ordered
{
get { return _element.Ordered; }
set { _element.Ordered = value; }
}
public TimeSpan InactivityTimeout
{
get { return _element.InactivityTimeout; }
set
{
if (value <= TimeSpan.Zero)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value,
SRP.ValueMustBePositive));
_element.InactivityTimeout = value;
}
}
internal void CopySettings(ReliableSession copyFrom)
{
Ordered = copyFrom.Ordered;
InactivityTimeout = copyFrom.InactivityTimeout;
}
}
public class OptionalReliableSession : ReliableSession
{
public OptionalReliableSession() : base() { }
public OptionalReliableSession(ReliableSessionBindingElement reliableSessionBindingElement) : base(reliableSessionBindingElement) { }
// We don't include DefaultValue here because this defaults to false, so omitting it would make the XAML somewhat misleading
public bool Enabled { get; set; }
internal void CopySettings(OptionalReliableSession copyFrom)
{
base.CopySettings(copyFrom);
Enabled = copyFrom.Enabled;
}
}
}