2 // CustomPolicyConversionContext.cs
5 // Martin Baulig <martin.baulig@xamarin.com>
7 // Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 using System.ServiceModel.Channels;
30 using WS = System.Web.Services.Description;
32 namespace System.ServiceModel.Description {
34 internal class CustomPolicyConversionContext : PolicyConversionContext {
36 PolicyAssertionCollection assertions;
37 BindingElementCollection binding_elements;
39 internal WS.Binding WsdlBinding {
40 get { return binding; }
43 #region implemented abstract members of PolicyConversionContext
45 public override PolicyAssertionCollection GetBindingAssertions ()
50 public override PolicyAssertionCollection GetFaultBindingAssertions (FaultDescription fault)
52 throw new NotImplementedException ();
55 public override PolicyAssertionCollection GetMessageBindingAssertions (MessageDescription message)
57 throw new NotImplementedException ();
60 public override PolicyAssertionCollection GetOperationBindingAssertions (OperationDescription operation)
62 throw new NotImplementedException ();
65 public override BindingElementCollection BindingElements {
67 return binding_elements;
73 public CustomPolicyConversionContext (WS.Binding binding, ServiceEndpoint endpoint)
76 this.binding = binding;
77 assertions = new PolicyAssertionCollection ();
78 binding_elements = ((CustomBinding)endpoint.Binding).Elements;
81 public void AddPolicyAssertion (XmlElement element)
84 * http://www.w3.org/Submission/WS-Policy/#Policy_Assertion:
88 * ( <wsp:All> ( <Assertion …> … </Assertion> )* </wsp:All> )*
94 var exactlyOne = element.FirstChild as XmlElement;
95 if (exactlyOne == null) {
100 if (!exactlyOne.NamespaceURI.Equals (Constants.WspNamespace) ||
101 !exactlyOne.LocalName.Equals ("ExactlyOne")) {
102 // FIXME: What to do with this ... ?
106 foreach (var node in exactlyOne.ChildNodes) {
107 var child = node as XmlElement;
111 if (!child.NamespaceURI.Equals (Constants.WspNamespace) ||
112 !child.LocalName.Equals ("All")) {
113 // FIXME: Can assertions go here ... ?
117 foreach (var node2 in child.ChildNodes) {
118 var assertion = node2 as XmlElement;
119 if (assertion == null)
122 assertions.Add (assertion);