[Mono-dev] (WCF) Binding elements order

Thiago Padilha tpadilha84 at gmail.com
Tue Jul 6 08:34:30 EDT 2010


  Hi Atsushi,

  While examining the file "Binding.cs" I found the following comment
on the two overloads of "CreateContext" method :

"
// FIXME: it seems that binding elements are
// "validated" so that the last item is a transport.
"
  If you were unsure about where the binding elements should be
ordered take a look at this :
http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.binding.createbindingelements.aspx
  According to this document, the ordering should be done inside the
"CreateBindingElements" method for any class that inherits from
"Binding". This could be fixed by using the following code in
"CustomBinding.cs" :

public override BindingElementCollection CreateBindingElements ()
		{
			return new BindingElementCollection (elements.OrderBy (be =>
			{
				Type t = be.GetType ();
				if (typeof(TransportBindingElement).IsAssignableFrom (t))
					return 2;
				if (typeof(MessageEncodingBindingElement).IsAssignableFrom (t))
					return 1;
				return 0;
			}));			
		}


More information about the Mono-devel-list mailing list