我有一个XML序列化的类对象
[XmlType("PAYMENT")]
public class PaymentXML
{
[XmlElement(ElementName = "REQUEST")]
public RequestXML Request { get; set; }
[XmlElement(ElementName = "META")]
public MetaXML Request { get; set; }
//Property that I dont want to be serialized
public Subscriber Subscriber { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
序列化
var xml = new PaymentXML();
string path = HttpContext.Current.Server.MapPath(@_xmlResponseDir + _responsePath);
using (var sw = new StreamWriter(path))
{
var ns = new XmlSerializerNamespaces();
ns.Add("", "");
var serializer = new XmlSerializer(typeof(PaymentXML), new XmlRootAttribute("XML"));
serializer.Serialize(sw, xml, ns);
}
Run Code Online (Sandbox Code Playgroud)
问题是,它还在序列化 …
我打算使用EF(POCO)生成的实体向客户端发送数据而不是创建DTO?这是一个好习惯吗?基本上,我的EDMX文件在我的DAL层上.因此,用户界面将直接访问我的DAL.谢谢.
我很难将这个代码段转换为VB.NET
Function DecryptPassword(ByVal s As String) As String
Dim i As Integer
Dim sPass As String = s.Trim()
For i = 1 To Len(sPass)
If Asc(Mid$(sPass, i, 1)) - 5 < 124 Then
'this line throws "type char $ does not match declared data type char"
Mid$(sPass, i, 1) = Chr$(Asc(Mid$(sPass, i, 1)) - 5)
Else
Mid$(sPass, i, 1) = Mid$(sPass, i, 1)
End If
Next
DecryptPassword = UCase(sPass) ' Convert UserPassword to UpperCase
End Function
Run Code Online (Sandbox Code Playgroud)
它在VB6中运行良好但在VB.Net时抛出错误..