File: UdpBindingElement.cs

package info (click to toggle)
mono 6.14.1%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,282,732 kB
  • sloc: cs: 11,182,461; xml: 2,850,281; ansic: 699,123; cpp: 122,919; perl: 58,604; javascript: 30,841; asm: 21,845; makefile: 19,602; sh: 10,973; python: 4,772; pascal: 925; sql: 859; sed: 16; php: 1
file content (130 lines) | stat: -rw-r--r-- 6,751 bytes parent folder | download | duplicates (7)
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
//-----------------------------------------------------------------------------

namespace System.ServiceModel.Configuration
{
    using System.ComponentModel;
    using System.Configuration;
    using System.Diagnostics.CodeAnalysis;
    using System.Runtime;
    using System.ServiceModel.Channels;
    using System.Text;

    public partial class UdpBindingElement : StandardBindingElement
    {
        public UdpBindingElement(string name)
            : base(name)
        {
        }

        public UdpBindingElement()
            : this(null)
        {
        }
        
        protected override Type BindingElementType
        {
            get { return typeof(UdpBinding); }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.DuplicateMessageHistoryLength, DefaultValue = UdpConstants.Defaults.DuplicateMessageHistoryLength)]
        [IntegerValidator(MinValue = 0)]
        public int DuplicateMessageHistoryLength
        {
            get { return (int)base[UdpTransportConfigurationStrings.DuplicateMessageHistoryLength]; }
            set { base[UdpTransportConfigurationStrings.DuplicateMessageHistoryLength] = value; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.MaxBufferPoolSize, DefaultValue = TransportDefaults.MaxBufferPoolSize)]
        [LongValidator(MinValue = 0)]
        public long MaxBufferPoolSize
        {
            get { return (long)base[UdpTransportConfigurationStrings.MaxBufferPoolSize]; }
            set { base[UdpTransportConfigurationStrings.MaxBufferPoolSize] = value; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.MaxRetransmitCount, DefaultValue = UdpConstants.Defaults.MaxRetransmitCount)]
        [IntegerValidator(MinValue = 0)]
        public int MaxRetransmitCount
        {
            get { return (int)base[UdpTransportConfigurationStrings.MaxRetransmitCount]; }
            set { base[UdpTransportConfigurationStrings.MaxRetransmitCount] = value; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.MaxPendingMessagesTotalSize, DefaultValue = UdpConstants.Defaults.DefaultMaxPendingMessagesTotalSize)]
        [LongValidator(MinValue = UdpConstants.MinPendingMessagesTotalSize)]
        public long MaxPendingMessagesTotalSize
        {
            get { return (long)base[UdpTransportConfigurationStrings.MaxPendingMessagesTotalSize]; }
            set { base[UdpTransportConfigurationStrings.MaxPendingMessagesTotalSize] = value; }
        }

        // Min value has to be 1, because it's 1 in the TransportBindingElement
        [ConfigurationProperty(UdpTransportConfigurationStrings.MaxReceivedMessageSize, DefaultValue = UdpConstants.Defaults.MaxReceivedMessageSize)]
        [LongValidator(MinValue = 1)]
        public long MaxReceivedMessageSize
        {
            get { return (long)this[UdpTransportConfigurationStrings.MaxReceivedMessageSize]; }
            set { this[UdpTransportConfigurationStrings.MaxReceivedMessageSize] = value; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.MulticastInterfaceId, DefaultValue = UdpConstants.Defaults.MulticastInterfaceId)]
        [StringValidator()]
        public string MulticastInterfaceId
        {
            get { return (string)base[UdpTransportConfigurationStrings.MulticastInterfaceId]; }
            set { base[UdpTransportConfigurationStrings.MulticastInterfaceId] = value; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.ReaderQuotas)]
        public XmlDictionaryReaderQuotasElement ReaderQuotas
        {
            get { return (XmlDictionaryReaderQuotasElement)base[UdpTransportConfigurationStrings.ReaderQuotas]; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.TextEncoding, DefaultValue = UdpConstants.Defaults.EncodingString)]
        [TypeConverter(typeof(EncodingConverter))]
        [SuppressMessage(FxCop.Category.Configuration, FxCop.Rule.ConfigurationValidatorAttributeRule, Justification = "this property not a configuration property")]
        public Encoding TextEncoding
        {
            get { return (Encoding)base[UdpTransportConfigurationStrings.TextEncoding]; }
            set { base[UdpTransportConfigurationStrings.TextEncoding] = value; }
        }

        [ConfigurationProperty(UdpTransportConfigurationStrings.TimeToLive, DefaultValue = UdpConstants.Defaults.TimeToLive)]
        [IntegerValidator(MinValue = UdpConstants.MinTimeToLive, MaxValue = UdpConstants.MaxTimeToLive)]
        public int TimeToLive
        {
            get { return (int)base[UdpTransportConfigurationStrings.TimeToLive]; }
            set { base[UdpTransportConfigurationStrings.TimeToLive] = value; }
        }

        protected internal override void InitializeFrom(Binding binding)
        {
            base.InitializeFrom(binding);
            UdpBinding udpBinding = (UdpBinding)binding;

            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.DuplicateMessageHistoryLength, udpBinding.DuplicateMessageHistoryLength);
            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.MaxBufferPoolSize, udpBinding.MaxBufferPoolSize);
            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.MaxRetransmitCount, udpBinding.MaxRetransmitCount);
            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.MaxPendingMessagesTotalSize, udpBinding.MaxPendingMessagesTotalSize);
            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.MaxReceivedMessageSize, udpBinding.MaxReceivedMessageSize);
            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.MulticastInterfaceId, udpBinding.MulticastInterfaceId);
            this.SetPropertyValueIfNotDefaultValue(UdpTransportConfigurationStrings.TimeToLive, udpBinding.TimeToLive);
        }

        protected override void OnApplyConfiguration(Binding binding)
        {
            UdpBinding udpBinding = (UdpBinding)binding;

            udpBinding.DuplicateMessageHistoryLength = this.DuplicateMessageHistoryLength;
            udpBinding.MaxBufferPoolSize = this.MaxBufferPoolSize;
            udpBinding.MaxRetransmitCount = this.MaxRetransmitCount;
            udpBinding.MaxPendingMessagesTotalSize = this.MaxPendingMessagesTotalSize;
            udpBinding.MaxReceivedMessageSize = this.MaxReceivedMessageSize;
            udpBinding.MulticastInterfaceId = this.MulticastInterfaceId;
            udpBinding.TimeToLive = this.TimeToLive;
        }
    }
}