public override BindingElementCollection CreateBindingElements() { BindingElementCollection bc = base.CreateBindingElements(); // message security element is returned only when // it is enabled (while CreateMessageSecurity() still // returns non-null instance). switch (Security.Mode) { case SecurityMode.None: case SecurityMode.Transport: bc.RemoveAll <SecurityBindingElement> (); break; } return(bc); }