本文整理汇总了C#中Protocol.Matches方法的典型用法代码示例。如果您正苦于以下问题:C# Protocol.Matches方法的具体用法?C# Protocol.Matches怎么用?C# Protocol.Matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Protocol
的用法示例。
在下文中一共展示了Protocol.Matches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitializeEncodings
/// <summary>
/// Initializes the message encodings dropdown.
/// </summary>
private void InitializeEncodings(EndpointDescriptionCollection endpoints, EndpointDescription endpoint)
{
// preserve the existing value.
Encoding currentEncoding = Encoding.Default;
if (EncodingCB.SelectedIndex != -1)
{
currentEncoding = (Encoding)EncodingCB.SelectedItem;
}
EncodingCB.Items.Clear();
if (endpoint != null)
{
Protocol protocol = new Protocol(endpoint);
String securityPolicy = SecurityPolicies.GetDisplayName(endpoint.SecurityPolicyUri);
foreach (EndpointDescription endpointDescription in endpoints)
{
if ((protocol.Matches(Utils.ParseUri(endpointDescription.EndpointUrl))) &&
(endpoint.SecurityMode == endpointDescription.SecurityMode) &&
(securityPolicy == SecurityPolicies.GetDisplayName(endpointDescription.SecurityPolicyUri)))
{
switch (endpointDescription.EncodingSupport)
{
case BinaryEncodingSupport.None:
{
if (!EncodingCB.Items.Contains(Encoding.Xml))
{
EncodingCB.Items.Add(Encoding.Xml);
}
break;
}
case BinaryEncodingSupport.Required:
{
if (!EncodingCB.Items.Contains(Encoding.Binary))
{
EncodingCB.Items.Add(Encoding.Binary);
}
break;
}
case BinaryEncodingSupport.Optional:
{
if (!EncodingCB.Items.Contains(Encoding.Binary))
{
EncodingCB.Items.Add(Encoding.Binary);
}
if (!EncodingCB.Items.Contains(Encoding.Xml))
{
EncodingCB.Items.Add(Encoding.Xml);
}
break;
}
}
}
}
}
// add at least one encoding.
if (EncodingCB.Items.Count == 0)
{
EncodingCB.Items.Add(Encoding.Default);
}
// set the current value.
int index = EncodingCB.Items.IndexOf(currentEncoding);
if (index == -1)
{
index = 0;
}
EncodingCB.SelectedIndex = index;
}