當前位置: 首頁>>代碼示例>>C#>>正文


C# WsdlImporter.AddWarning方法代碼示例

本文整理匯總了C#中System.ServiceModel.Description.WsdlImporter.AddWarning方法的典型用法代碼示例。如果您正苦於以下問題:C# WsdlImporter.AddWarning方法的具體用法?C# WsdlImporter.AddWarning怎麽用?C# WsdlImporter.AddWarning使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ServiceModel.Description.WsdlImporter的用法示例。


在下文中一共展示了WsdlImporter.AddWarning方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ImportNetTcpBinding

		bool ImportNetTcpBinding (
			WsdlImporter importer, WsdlEndpointConversionContext context,
			CustomBinding custom, WS.Soap12Binding soap)
		{
			TcpTransportBindingElement transportElement = null;
			BinaryMessageEncodingBindingElement binaryElement = null;
			TransactionFlowBindingElement transactionFlowElement = null;
			WindowsStreamSecurityBindingElement windowsStreamElement = null;
			SslStreamSecurityBindingElement sslStreamElement = null;
			bool foundUnknownElement = false;
			
			foreach (var element in custom.Elements) {
				if (element is TcpTransportBindingElement)
					transportElement = (TcpTransportBindingElement)element;
				else if (element is BinaryMessageEncodingBindingElement)
					binaryElement = (BinaryMessageEncodingBindingElement)element;
				else if (element is TransactionFlowBindingElement)
					transactionFlowElement = (TransactionFlowBindingElement)element;
				else if (element is WindowsStreamSecurityBindingElement)
					windowsStreamElement = (WindowsStreamSecurityBindingElement)element;
				else if (element is SslStreamSecurityBindingElement)
					sslStreamElement = (SslStreamSecurityBindingElement)element;
				else {
					importer.AddWarning (
						"Found unknown binding element `{0}' while importing " +
						"binding `{1}'.", element.GetType (), custom.Name);
					foundUnknownElement = true;
				}
			}

			if (foundUnknownElement)
				return false;

			if (transportElement == null) {
				importer.AddWarning (
					"Missing TcpTransportBindingElement while importing " +
					"binding `{0}'.", custom.Name);
				return false;
			}
			if (binaryElement == null) {
				importer.AddWarning (
					"Missing BinaryMessageEncodingBindingElement while importing " +
					"binding `{0}'.", custom.Name);
				return false;
			}

			if ((windowsStreamElement != null) && (sslStreamElement != null)) {
				importer.AddWarning (
					"Found both WindowsStreamSecurityBindingElement and " +
					"SslStreamSecurityBindingElement while importing binding `{0}.",
					custom.Name);
				return false;
			}

			NetTcpSecurity security;
			if (windowsStreamElement != null) {
				security = new NetTcpSecurity (SecurityMode.Transport);
				security.Transport.ProtectionLevel = windowsStreamElement.ProtectionLevel;
			} else if (sslStreamElement != null) {
				security = new NetTcpSecurity (SecurityMode.TransportWithMessageCredential);
			} else {
				security = new NetTcpSecurity (SecurityMode.None);
			}

			var netTcp = new NetTcpBinding (transportElement, security, false);

			netTcp.Name = context.Endpoint.Binding.Name;
			netTcp.Namespace = context.Endpoint.Binding.Namespace;

			context.Endpoint.Binding = netTcp;
			return true;
		}
開發者ID:nlhepler,項目名稱:mono,代碼行數:72,代碼來源:StandardBindingImporter.cs

示例2: ImportBasicHttpBinding

		bool ImportBasicHttpBinding (
			WsdlImporter importer, WsdlEndpointConversionContext context,
			CustomBinding custom, WS.SoapBinding soap)
		{
			TransportBindingElement transportElement = null;
			MtomMessageEncodingBindingElement mtomElement = null;
			TextMessageEncodingBindingElement textElement = null;
			bool foundUnknownElement = false;

			foreach (var element in custom.Elements) {
				if (element is TransportBindingElement)
					transportElement = (TransportBindingElement)element;
				else if (element is MtomMessageEncodingBindingElement)
					mtomElement = (MtomMessageEncodingBindingElement)element;
				else if (element is TextMessageEncodingBindingElement)
					textElement = (TextMessageEncodingBindingElement)element;
				else {
					importer.AddWarning (
						"Found unknown binding element `{0}' while attempting " +
						"to import binding `{0}'.", element.GetType (),
						custom.Name);
					foundUnknownElement = true;
				}
			}

			if (foundUnknownElement)
				return false;

			if ((mtomElement != null) && (textElement != null)) {
				// FIXME: Should never happen
				importer.AddWarning (
					"Found both MtomMessageEncodingBindingElement and " +
					"TextMessageEncodingBindingElement while attempting to " +
					"import binding `{0}'.", custom.Name);
				return false;
			}

			BasicHttpBinding httpBinding;
			AuthenticationSchemes authScheme;

			/*
			 * FIXME: Maybe make the BasicHttpBinding use the transport element
			 * that we created with the TransportBindingElementImporter ?
			 * 
			 * There seems to be no public API to do that, so maybe add a private .ctor ?
			 * 
			 */

			var httpsTransport = transportElement as HttpsTransportBindingElement;
			var httpTransport = transportElement as HttpTransportBindingElement;

			if (httpsTransport != null) {
				httpBinding = new BasicHttpBinding (BasicHttpSecurityMode.Transport);
				authScheme = httpsTransport.AuthenticationScheme;
			} else if (httpTransport != null) {
				authScheme = httpTransport.AuthenticationScheme;
				if ((authScheme != AuthenticationSchemes.None) &&
					(authScheme != AuthenticationSchemes.Anonymous))
					httpBinding = new BasicHttpBinding (
						BasicHttpSecurityMode.TransportCredentialOnly);
				else
					httpBinding = new BasicHttpBinding ();
			} else {
				httpBinding = new BasicHttpBinding ();
				authScheme = AuthenticationSchemes.Anonymous;
			}

			if (mtomElement != null)
				httpBinding.MessageEncoding = WSMessageEncoding.Mtom;
			else if (textElement != null)
				httpBinding.MessageEncoding = WSMessageEncoding.Text;
			else {
				importer.AddWarning (
					"Found neither MtomMessageEncodingBindingElement nor " +
					"TextMessageEncodingBindingElement while attempting to " +
					"import binding `{0}'.", custom.Name);
				return false;
			}

			httpBinding.Name = context.Endpoint.Binding.Name;
			httpBinding.Namespace = context.Endpoint.Binding.Namespace;

			switch (authScheme) {
			case AuthenticationSchemes.None:
			case AuthenticationSchemes.Anonymous:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
				break;
			case AuthenticationSchemes.Basic:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
				break;
			case AuthenticationSchemes.Digest:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Digest;
				break;
			case AuthenticationSchemes.Ntlm:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;
				break;
			case AuthenticationSchemes.Negotiate:
				httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
				break;
			default:
//.........這裏部分代碼省略.........
開發者ID:nlhepler,項目名稱:mono,代碼行數:101,代碼來源:StandardBindingImporter.cs


注:本文中的System.ServiceModel.Description.WsdlImporter.AddWarning方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。