我必须转换System.Collections.Generic.IDictionary<string, decimal>为System.Collections.Generic.Dictionary<string, decimal>,而我不能.我尝试了ToDictionary方法,无法指定正确的参数.
我尝试过以下方法:
// my dictionary is PlannedSurfaces (of type IDictionary<string, decimal>)
blabla.ToDictionary<string, decimal>(localConstruction.PlannedSurfaces)
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我必须以任何格式(*.png,*.jpg,*.bmp等)比较两个图像,并返回百分比的相似率.
有没有人这样做?
如果有,怎么样?
服务器配置:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceCredentialsBehavior">
<serviceCredentials>
<serviceCertificate findValue="cn=cool" storeName="TrustedPeople" storeLocation="CurrentUser" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceCredentialsBehavior" name="Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MessageAndUserName" name="SecuredByTransportEndpoint" contract="IService"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client/>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
Run Code Online (Sandbox Code Playgroud)
我的客户端配置:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="LocalCertValidation">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="CurrentUser" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" >
<security mode="Message"> …Run Code Online (Sandbox Code Playgroud) 我已经设置了SmtpClient类的Timeout属性,但它似乎不起作用,当我给它一个1毫秒的值时,执行代码时超时实际上是15秒.我从msdn获取的代码.
string to = "jane@contoso.com";
string from = "ben@contoso.com";
string subject = "Using the new SMTP client.";
string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient("1.2.3.4");
Console.WriteLine("Changing time out from {0} to 100.", client.Timeout);
client.Timeout = 1;
// Credentials are necessary if the server requires the client
// to authenticate before it will send e-mail on …Run Code Online (Sandbox Code Playgroud) 由于文档很少,我在C#中遇到OpenXml SpreadSheetDocument问题.
我在我的本地计算机上进行了用户名/密码验证,使用自签名证书,一切正常,但是当我将我的应用程序放在IIS 7.5和Windows Server 2008 R2上时,它给了我错误:
无法找到一个基地址匹配具有绑定WSHttpBinding的端点的scheme http.注册的基地址方案是[https].
我的网络服务cfg:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceCredentialsBehavior">
<serviceCredentials>
<serviceCertificate findValue="cn=AmicCert" storeName="Root" storeLocation="LocalMachine" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Util.CustomUserNameValidator, Util" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceCredentialsBehavior" name="Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MessageAndUserName" name="SecuredByTransportEndpoint" contract="IService" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client />
</system.serviceModel>
<system.web>
<compilation debug="true" />
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud) 可以使用两种类型的身份验证:wcf中的窗口和用户名,使用消息安全模式和证书进行身份验证.我的UserName身份验证cfg/code看起来:
Server cfg:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceCredentialsBehavior">
<serviceCredentials>
<serviceCertificate findValue="cn=cool" storeName="TrustedPeople" storeLocation="CurrentUser" />
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Util.CustomUserNameValidator, Util" />
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="ServiceCredentialsBehavior" name="Service">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MessageAndUserName" name="SecuredByTransportEndpoint" contract="IService"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="MessageAndUserName">
<security mode="Message">
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client/>
</system.serviceModel>
<system.web>
<compilation debug="true"/>
</system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)
客户cfg:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="LocalCertValidation">
<clientCredentials>
<serviceCertificate>
<authentication certificateValidationMode="PeerTrust" trustedStoreLocation="CurrentUser" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors> …Run Code Online (Sandbox Code Playgroud) 如何在Damerau-Levenshtein距离算法的实现中禁用删除计数,或者如果已经实现了其他算法,请指向我.
示例(禁用删除计数):
string1:你好吗?
string2:oyu怎么样?
距离: 1(换位,4次删除不计算)
这是算法:
public static int DamerauLevenshteinDistance(string string1, string string2, int threshold)
{
// Return trivial case - where they are equal
if (string1.Equals(string2))
return 0;
// Return trivial case - where one is empty
if (String.IsNullOrEmpty(string1) || String.IsNullOrEmpty(string2))
return (string1 ?? "").Length + (string2 ?? "").Length;
// Ensure string2 (inner cycle) is longer_transpositionRow
if (string1.Length > string2.Length)
{
var tmp = string1;
string1 = string2;
string2 = tmp;
}
// Return …Run Code Online (Sandbox Code Playgroud) 我想使用带有用户名/密码身份验证和ssl的传输安全模式,它适用于Windows身份验证:
<transport clientCredentialType="Windows"/>
Run Code Online (Sandbox Code Playgroud)
我在msdn上发现了一篇文章解释了如何使用传输安全模式进行用户名/密码身份验证,但需要自定义http模块.我感兴趣的是为什么没有默认安全模式,如:
<transport clientCredentialType="Username"/>
Run Code Online (Sandbox Code Playgroud)
如果我需要用户名/密码验证,我可以使用消息安全模式,但如果所有站点都使用https/ssl进行身份验证,那么在wcf中这样做应该不会有问题.
提前致谢.
c# ×8
.net ×5
wcf ×4
security ×2
web-services ×2
algorithm ×1
c#-4.0 ×1
certificate ×1
dictionary ×1
fuzzy ×1
generics ×1
https ×1
image ×1
openxml ×1
smtp ×1
timeout ×1
wcf-security ×1
xml ×1