假设我有一个Object ItemVO,其中已经分配了一堆属性.例如:
ItemVO originalItemVO = new ItemVO();
originalItemVO.ItemId = 1;
originalItemVO.ItemCategory = "ORIGINAL";
Run Code Online (Sandbox Code Playgroud)
我想通过使用以下方法创建另一个副本:
duplicateItemVO = originalItemVO;
Run Code Online (Sandbox Code Playgroud)
然后使用duplicateItemVO并更改其'属性,而不更改originalItemVO:
// This also change the originalItemVO.ItemCategory which I do not want.
duplicateItemVO.ItemCategory = "DUPLICATE"
Run Code Online (Sandbox Code Playgroud)
如何在不更改ItemVO类的情况下实现此目的?
谢谢
public class ItemVO
{
public ItemVO()
{
ItemId = "";
ItemCategory = "";
}
public string ItemId { get; set; }
public string ItemCategory { get; set; }
}
Run Code Online (Sandbox Code Playgroud) 谁能告诉我如何以编程方式创建具有端点行为的 WSHttpBindings?
这是从 WCF 添加服务引用到 6 个 WebServices 生成的,我手动编辑了这些 WebServices 以添加行为,以便所有端点都使用相同的行为。
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="epBehaviour">
<clientCredentials>
<clientCertificate findValue="This is my TEST Cert" storeLocation="LocalMachine" x509FindType="FindBySubjectName" storeName="My" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IQuote" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate" establishSecurityContext="false" />
</security>
</binding>
<binding name="WSHttpBinding_ICommit" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate" establishSecurityContext="false" />
</security>
</binding>
<binding name="WSHttpBinding_IRetrieve" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate" establishSecurityContext="false" />
</security>
</binding>
<binding name="WSHttpBinding_IInfo" messageEncoding="Mtom">
<security mode="TransportWithMessageCredential"> …Run Code Online (Sandbox Code Playgroud)