1- using System . Collections . Generic ;
2- using System . Runtime . Serialization ;
3- using ServiceStack . Logging ;
4- using ServiceStack . Logging . Support . Logging ;
5- using ServiceStack . ServiceHost ;
6- using ServiceStack . Text ;
7-
8- namespace ServiceStack . WebHost . Endpoints
9- {
10- public class EndpointHostConfig
11- {
12- private const string DefaultUsageExamplesBaseUri =
13- "http://code.google.com/p/servicestack/source/browse/trunk/doc/UsageExamples" ;
14-
15- public EndpointHostConfig ( )
16- {
17- this . UsageExamplesBaseUri = DefaultUsageExamplesBaseUri ;
18- this . ServiceEndpointsMetadataConfig = new ServiceEndpointsMetadataConfig {
19- DefaultMetadataUri = "Public/Metadata" ,
20- Soap11 = new SoapMetadataConfig ( "Public/Soap11/SyncReply.svc" , "Public/Soap11/AsyncOneWay.svc" , "Public/Soap11/Metadata" , "Public/Soap11/Wsdl" ) ,
21- Soap12 = new SoapMetadataConfig ( "Public/Soap12/SyncReply.svc" , "Public/Soap12/AsyncOneWay.svc" , "Public/Soap12/Metadata" , "Public/Soap12/Wsdl" ) ,
22- Xml = new MetadataConfig ( "Public/Xml/SyncReply" , "Public/Xml/AsyncOneWay" , "Public/Xml/Metadata" ) ,
23- Json = new MetadataConfig ( "Public/Json/SyncReply" , "Public/Json/AsyncOneWay" , "Public/Json/Metadata" ) ,
24- Jsv = new MetadataConfig ( "Public/Jsv/SyncReply" , "Public/Jsv/AsyncOneWay" , "Public/Jsv/Metadata" ) ,
25- } ;
26- this . LogFactory = new NullLogFactory ( ) ;
27- this . EnableAccessRestrictions = true ;
28-
29- this . GlobalResponseHeaders = new Dictionary < string , string >
30- { { "X-Powered-By" , Env . ServerUserAgent } } ;
31- }
32-
33- public IServiceController ServiceController { get ; set ; }
34- public string UsageExamplesBaseUri { get ; set ; }
35- public string ServiceName { get ; set ; }
36- public ServiceEndpointsMetadataConfig ServiceEndpointsMetadataConfig { get ; set ; }
37- public ILogFactory LogFactory { get ; set ; }
38- public bool EnableAccessRestrictions { get ; set ; }
39- public bool UseBclJsonSerializers { get ; set ; }
40- public Dictionary < string , string > GlobalResponseHeaders { get ; set ; }
41-
42- private string defaultOperationNamespace ;
43- public string DefaultOperationNamespace
44- {
45- get
46- {
47- if ( this . defaultOperationNamespace == null )
48- {
49- this . defaultOperationNamespace = GetDefaultNamespace ( ) ;
50- }
51- return this . defaultOperationNamespace ;
52- }
53- set
54- {
55- this . defaultOperationNamespace = value ;
56- }
57- }
58-
59- private string GetDefaultNamespace ( )
60- {
61- if ( ! string . IsNullOrEmpty ( this . defaultOperationNamespace )
62- || this . ServiceController == null ) return null ;
63-
64- foreach ( var operationType in this . ServiceController . OperationTypes )
65- {
66- var attrs = operationType . GetCustomAttributes (
67- typeof ( DataContractAttribute ) , false ) ;
68-
69- if ( attrs . Length <= 0 ) continue ;
70-
71- var attr = ( DataContractAttribute ) attrs [ 0 ] ;
72-
73- if ( string . IsNullOrEmpty ( attr . Namespace ) ) continue ;
74-
75- return attr . Namespace ;
76- }
77-
78- return null ;
79- }
80-
81- }
1+ using System . Collections . Generic ;
2+ using System . Runtime . Serialization ;
3+ using ServiceStack . Logging ;
4+ using ServiceStack . Logging . Support . Logging ;
5+ using ServiceStack . ServiceHost ;
6+ using ServiceStack . Text ;
7+ using ServiceStack . WebHost . Endpoints . Support ;
8+
9+ namespace ServiceStack . WebHost . Endpoints
10+ {
11+ public class EndpointHostConfig
12+ {
13+ private const string DefaultUsageExamplesBaseUri =
14+ "http://code.google.com/p/servicestack/source/browse/trunk/doc/UsageExamples" ;
15+
16+ public EndpointHostConfig ( )
17+ {
18+ this . UsageExamplesBaseUri = DefaultUsageExamplesBaseUri ;
19+ this . ServiceEndpointsMetadataConfig = new ServiceEndpointsMetadataConfig {
20+ DefaultMetadataUri = "Public/Metadata" ,
21+ Soap11 = new SoapMetadataConfig ( "Public/Soap11/SyncReply.svc" , "Public/Soap11/AsyncOneWay.svc" , "Public/Soap11/Metadata" , "Public/Soap11/Wsdl" ) ,
22+ Soap12 = new SoapMetadataConfig ( "Public/Soap12/SyncReply.svc" , "Public/Soap12/AsyncOneWay.svc" , "Public/Soap12/Metadata" , "Public/Soap12/Wsdl" ) ,
23+ Xml = new MetadataConfig ( "Public/Xml/SyncReply" , "Public/Xml/AsyncOneWay" , "Public/Xml/Metadata" ) ,
24+ Json = new MetadataConfig ( "Public/Json/SyncReply" , "Public/Json/AsyncOneWay" , "Public/Json/Metadata" ) ,
25+ Jsv = new MetadataConfig ( "Public/Jsv/SyncReply" , "Public/Jsv/AsyncOneWay" , "Public/Jsv/Metadata" ) ,
26+ } ;
27+ this . LogFactory = new NullLogFactory ( ) ;
28+ this . EnableAccessRestrictions = true ;
29+ this . DefaultContentType = ContentType . Json ;
30+
31+ this . GlobalResponseHeaders = new Dictionary < string , string >
32+ { { "X-Powered-By" , Env . ServerUserAgent } } ;
33+ }
34+
35+ public IServiceController ServiceController { get ; set ; }
36+ public string UsageExamplesBaseUri { get ; set ; }
37+ public string ServiceName { get ; set ; }
38+ public string DefaultContentType { get ; set ; }
39+ public ServiceEndpointsMetadataConfig ServiceEndpointsMetadataConfig { get ; set ; }
40+ public ILogFactory LogFactory { get ; set ; }
41+ public bool EnableAccessRestrictions { get ; set ; }
42+ public bool UseBclJsonSerializers { get ; set ; }
43+ public Dictionary < string , string > GlobalResponseHeaders { get ; set ; }
44+
45+ private string defaultOperationNamespace ;
46+ public string DefaultOperationNamespace
47+ {
48+ get
49+ {
50+ if ( this . defaultOperationNamespace == null )
51+ {
52+ this . defaultOperationNamespace = GetDefaultNamespace ( ) ;
53+ }
54+ return this . defaultOperationNamespace ;
55+ }
56+ set
57+ {
58+ this . defaultOperationNamespace = value ;
59+ }
60+ }
61+
62+ private string GetDefaultNamespace ( )
63+ {
64+ if ( ! string . IsNullOrEmpty ( this . defaultOperationNamespace )
65+ || this . ServiceController == null ) return null ;
66+
67+ foreach ( var operationType in this . ServiceController . OperationTypes )
68+ {
69+ var attrs = operationType . GetCustomAttributes (
70+ typeof ( DataContractAttribute ) , false ) ;
71+
72+ if ( attrs . Length <= 0 ) continue ;
73+
74+ var attr = ( DataContractAttribute ) attrs [ 0 ] ;
75+
76+ if ( string . IsNullOrEmpty ( attr . Namespace ) ) continue ;
77+
78+ return attr . Namespace ;
79+ }
80+
81+ return null ;
82+ }
83+
84+ }
8285}
0 commit comments