Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mcs / class / System.ServiceModel.Web / System.ServiceModel.Configuration / WebScriptEndpointElement.cs
1 //
2 // Author:
3 //      Atsushi Enomoto <atsushi@ximian.com>
4 //
5 // Copyright (C) 2010 Novell, Inc.  http://www.novell.com
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining
8 // a copy of this software and associated documentation files (the
9 // "Software"), to deal in the Software without restriction, including
10 // without limitation the rights to use, copy, modify, merge, publish,
11 // distribute, sublicense, and/or sell copies of the Software, and to
12 // permit persons to whom the Software is furnished to do so, subject to
13 // the following conditions:
14 // 
15 // The above copyright notice and this permission notice shall be
16 // included in all copies or substantial portions of the Software.
17 // 
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26
27 using System;
28 using System.Collections;
29 using System.Collections.Generic;
30 using System.Collections.ObjectModel;
31 using System.ComponentModel;
32 using System.Configuration;
33 using System.Reflection;
34 using System.ServiceModel;
35 using System.ServiceModel.Channels;
36 using System.ServiceModel.Description;
37 using System.ServiceModel.Diagnostics;
38 using System.ServiceModel.Dispatcher;
39 using System.ServiceModel.MsmqIntegration;
40 using System.ServiceModel.PeerResolvers;
41 using System.ServiceModel.Security;
42 using System.ServiceModel.Web;
43 using System.Runtime.Serialization;
44 using System.Text;
45 using System.Xml;
46
47 namespace System.ServiceModel.Configuration
48 {
49         public class WebScriptEndpointElement : StandardEndpointElement
50         {
51                 static ConfigurationPropertyCollection properties = new ConfigurationPropertyCollection ();
52
53                 static ConfigurationProperty content_type_mapper, cross_domain_script_access_enabled, host_name_comparison_mode, max_buffer_pool_size, max_buffer_size, max_received_message_size, reader_quotas, security, transfer_mode, write_encoding;
54
55                 static WebScriptEndpointElement ()
56                 {
57                         content_type_mapper = new ConfigurationProperty ("contentTypeMapper", typeof (string), "", null, null, ConfigurationPropertyOptions.None);
58                         cross_domain_script_access_enabled = new ConfigurationProperty ("crossDomainScriptAccessEnabled", typeof (bool), false, null, null, ConfigurationPropertyOptions.None);
59                         host_name_comparison_mode = new ConfigurationProperty ("hostNameComparisonMode", typeof (HostNameComparisonMode), HostNameComparisonMode.StrongWildcard, null, null, ConfigurationPropertyOptions.None);
60                         max_buffer_pool_size = new ConfigurationProperty ("maxBufferPoolSize", typeof (long), 0x80000, null, null, ConfigurationPropertyOptions.None);
61                         max_buffer_size = new ConfigurationProperty ("maxBufferSize", typeof (int), 0x10000, null, null, ConfigurationPropertyOptions.None);
62                         max_received_message_size = new ConfigurationProperty ("maxReceivedMessageSize", typeof (long), 0x10000, null, null, ConfigurationPropertyOptions.None);
63                         reader_quotas = new ConfigurationProperty ("readerQuotas", typeof (XmlDictionaryReaderQuotas), null, null, null, ConfigurationPropertyOptions.None);
64                         security = new ConfigurationProperty ("security", typeof (WebHttpSecurity), null, null, null, ConfigurationPropertyOptions.None);
65                         transfer_mode = new ConfigurationProperty ("transferMode", typeof (TransferMode), TransferMode.Buffered, null, null, ConfigurationPropertyOptions.None);
66                         write_encoding = new ConfigurationProperty ("writeEncoding", typeof (Encoding), "utf-8", new EncodingConverter (), null, ConfigurationPropertyOptions.None);
67
68                         foreach (var item in new ConfigurationProperty [] {content_type_mapper, cross_domain_script_access_enabled, host_name_comparison_mode, max_buffer_pool_size, max_buffer_size, max_received_message_size, reader_quotas, security, transfer_mode, write_encoding})
69                                 properties.Add (item);
70                 }
71
72                 protected internal override Type EndpointType {
73                         get { return typeof (WebScriptEndpoint); }
74                 }
75
76                 protected override ConfigurationPropertyCollection Properties {
77                         get { return properties; }
78                 }
79
80                 [ConfigurationProperty ("contentTypeMapper", DefaultValue = "")]
81                 [StringValidator (MinLength = 0)]
82                 public string ContentTypeMapper {
83                         get { return (string) this ["contentTypeMapper"]; }
84                         set { this ["contentTypeMapper"] = value; }
85                 }
86
87                 [ConfigurationProperty ("crossDomainScriptAccessEnabled", DefaultValue = false)]
88                 public bool CrossDomainScriptAccessEnabled {
89                         get { return (bool) this ["crossDomainScriptAccessEnabled"]; }
90                         set { this ["crossDomainScriptAccessEnabled"] = value; }
91                 }
92
93                 [ConfigurationProperty ("hostNameComparisonMode", DefaultValue = HostNameComparisonMode.StrongWildcard)]
94                 public HostNameComparisonMode HostNameComparisonMode {
95                         get { return (HostNameComparisonMode) this ["hostNameComparisonMode"]; }
96                         set { this ["hostNameComparisonMode"] = value; }
97                 }
98
99                 [LongValidator (MinValue = 0, MaxValue = long.MaxValue, ExcludeRange = false)]
100                 [ConfigurationProperty ("maxBufferPoolSize", DefaultValue = 0x80000,
101                          Options = ConfigurationPropertyOptions.None)]
102                 public long MaxBufferPoolSize {
103                         get { return (long) this ["maxBufferPoolSize"]; }
104                         set { this ["maxBufferPoolSize"] = value; }
105                 }
106
107                 [IntegerValidator ( MinValue = 1,
108                         MaxValue = int.MaxValue,
109                         ExcludeRange = false)]
110                 [ConfigurationProperty ("maxBufferSize", DefaultValue = 0x10000,
111                          Options = ConfigurationPropertyOptions.None)]
112                 public int MaxBufferSize {
113                         get { return (int) this ["maxBufferSize"]; }
114                         set { this ["maxBufferSize"] = value; }
115                 }
116
117                 [LongValidator ( MinValue = 1, MaxValue = long.MaxValue, ExcludeRange = false)]
118                 [ConfigurationProperty ("maxReceivedMessageSize", DefaultValue = 0x10000,
119                          Options = ConfigurationPropertyOptions.None)]
120                 public long MaxReceivedMessageSize {
121                         get { return (long) this ["maxReceivedMessageSize"]; }
122                         set { this ["maxReceivedMessageSize"] = value; }
123                 }
124
125                 [ConfigurationProperty ("readerQuotas")]
126                 public XmlDictionaryReaderQuotasElement ReaderQuotas {
127                         get { return (XmlDictionaryReaderQuotasElement) this ["readerQuotas"]; }
128                 }
129
130                 [ConfigurationProperty ("security")]
131                 public WebHttpSecurityElement Security {
132                         get { return (WebHttpSecurityElement) this ["security"]; }
133                 }
134
135                 [ConfigurationProperty ("transferMode", DefaultValue = TransferMode.Buffered)]
136                 public TransferMode TransferMode {
137                         get { return (TransferMode) this ["transferMode"]; }
138                         set { this ["transferMode"] = value; }
139                 }
140
141                 [TypeConverter (typeof (EncodingConverter))]
142                 [ConfigurationProperty ("writeEncoding", DefaultValue = "utf-8")]
143                 public Encoding WriteEncoding {
144                         get { return (Encoding) this ["writeEncoding"]; }
145                         set { this ["writeEncoding"] = value; }
146                 }
147
148                 protected internal override ServiceEndpoint CreateServiceEndpoint (ContractDescription contractDescription)
149                 {
150                         throw new NotImplementedException ();
151                 }
152
153                 protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ChannelEndpointElement serviceEndpointElement)
154                 {
155                         throw new NotImplementedException ();
156                 }
157
158                 protected override void OnApplyConfiguration (ServiceEndpoint endpoint, ServiceEndpointElement serviceEndpointElement)
159                 {
160                         throw new NotImplementedException ();
161                 }
162
163                 protected override void OnInitializeAndValidate (ChannelEndpointElement channelEndpointElement)
164                 {
165                         throw new NotImplementedException ();
166                 }
167
168                 protected override void OnInitializeAndValidate (ServiceEndpointElement serviceEndpointElement)
169                 {
170                         throw new NotImplementedException ();
171                 }
172         }
173 }
174