0
|
1 using System;
|
|
2 using System.ServiceModel;
|
|
3 using System.ServiceModel.Channels;
|
|
4
|
|
5 using JetBrains.Annotations;
|
|
6
|
|
7 namespace BLToolkit.ServiceModel
|
|
8 {
|
|
9 using Data.Linq;
|
|
10
|
|
11 using NotNullAttribute = NotNullAttribute;
|
|
12
|
|
13 public class SoapDataContext : RemoteDataContextBase
|
|
14 {
|
|
15 #region Init
|
|
16
|
|
17 SoapDataContext()
|
|
18 {
|
|
19 }
|
|
20
|
|
21 public SoapDataContext([NotNull] string endpointConfigurationName)
|
|
22 : this()
|
|
23 {
|
|
24 if (endpointConfigurationName == null) throw new ArgumentNullException("endpointConfigurationName");
|
|
25
|
|
26 _endpointConfigurationName = endpointConfigurationName;
|
|
27 }
|
|
28
|
|
29 public SoapDataContext([NotNull] string endpointConfigurationName, [NotNull] string remoteAddress)
|
|
30 : this()
|
|
31 {
|
|
32 if (endpointConfigurationName == null) throw new ArgumentNullException("endpointConfigurationName");
|
|
33 if (remoteAddress == null) throw new ArgumentNullException("remoteAddress");
|
|
34
|
|
35 _endpointConfigurationName = endpointConfigurationName;
|
|
36 _remoteAddress = remoteAddress;
|
|
37 }
|
|
38
|
|
39 public SoapDataContext([NotNull] string endpointConfigurationName, [NotNull] EndpointAddress endpointAddress)
|
|
40 : this()
|
|
41 {
|
|
42 if (endpointConfigurationName == null) throw new ArgumentNullException("endpointConfigurationName");
|
|
43 if (endpointAddress == null) throw new ArgumentNullException("endpointAddress");
|
|
44
|
|
45 _endpointConfigurationName = endpointConfigurationName;
|
|
46 _endpointAddress = endpointAddress;
|
|
47 }
|
|
48
|
|
49 public SoapDataContext([NotNull] Binding binding, [NotNull] EndpointAddress endpointAddress)
|
|
50 : this()
|
|
51 {
|
|
52 if (binding == null) throw new ArgumentNullException("binding");
|
|
53 if (endpointAddress == null) throw new ArgumentNullException("endpointAddress");
|
|
54
|
|
55 Binding = binding;
|
|
56 _endpointAddress = endpointAddress;
|
|
57 }
|
|
58
|
|
59 string _endpointConfigurationName;
|
|
60 string _remoteAddress;
|
|
61 EndpointAddress _endpointAddress;
|
|
62
|
|
63 public Binding Binding { get; private set; }
|
|
64
|
|
65 #endregion
|
|
66
|
|
67 #region Overrides
|
|
68
|
|
69 protected override ILinqService GetClient()
|
|
70 {
|
|
71 if (Binding != null)
|
|
72 return new LinqSoapServiceClient(Binding, _endpointAddress);
|
|
73
|
|
74 if (_endpointAddress != null)
|
|
75 return new LinqSoapServiceClient(_endpointConfigurationName, _endpointAddress);
|
|
76
|
|
77 if (_remoteAddress != null)
|
|
78 return new LinqSoapServiceClient(_endpointConfigurationName, _remoteAddress);
|
|
79
|
|
80 return new LinqSoapServiceClient(_endpointConfigurationName);
|
|
81 }
|
|
82
|
|
83 protected override IDataContext Clone()
|
|
84 {
|
|
85 return new SoapDataContext
|
|
86 {
|
|
87 MappingSchema = MappingSchema,
|
|
88 Binding = Binding,
|
|
89 _endpointConfigurationName = _endpointConfigurationName,
|
|
90 _remoteAddress = _remoteAddress,
|
|
91 _endpointAddress = _endpointAddress,
|
|
92 };
|
|
93 }
|
|
94
|
|
95 protected override string ContextIDPrefix
|
|
96 {
|
|
97 get { return "LinqSoapService_"; }
|
|
98 }
|
|
99
|
|
100 #endregion
|
|
101 }
|
|
102 }
|