本文整理汇总了C#中XmlSerializer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlSerializer.ToString方法的具体用法?C# XmlSerializer.ToString怎么用?C# XmlSerializer.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlSerializer
的用法示例。
在下文中一共展示了XmlSerializer.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: delete
public void delete(List<EntityInterface> entitylist, string from)
{
string xmlData = "xmlData init";
XmlSerializer myserializer = new XmlSerializer(typeof(List<EntityInterface>));
xmlData = myserializer.ToString();
var stringwriter = new System.IO.StringWriter();
myserializer.Serialize(stringwriter, entitylist);
string Xml = stringwriter.ToString();
string url = "http://localhost:8080/EPU_Plugin/delete.html?from=" + from;
WebRequest request = WebRequest.Create(url);
byte[] requestBytes = Encoding.UTF8.GetBytes("&xml=" + Xml);
request.Method = "POST";
request.ContentType = "text/xml;charset=utf-16";
request.ContentLength = requestBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(requestBytes, 0, requestBytes.Length);
requestStream.Close();
HttpWebResponse res = (HttpWebResponse)request.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
string backstr = sr.ReadToEnd();
sr.Close();
res.Close();
MessageBox.Show(backstr);
}
示例2: ProcessRequest
public void ProcessRequest(Request request)
{
try
{
//myDAL = new DAL();
myBL = new BL();
String[] temppath = request.Url.Path.ToString().Split("/".ToCharArray()); // url parsen
Console.WriteLine(temppath[2]);
if (temppath[2].StartsWith("select"))
{
String[] switcher = temppath[0].Split("?".ToCharArray());
string xmlData = "xmlData init";
List<EntityInterface> liste = new List<EntityInterface>();
int useFake = 0;
if (request.Url.Parameter.ContainsKey("useFake")) { useFake = Convert.ToInt32(request.Url.Parameter["useFake"]); }
liste = myBL.check(request.Url.Parameter["search"], request.Url.Parameter["from"], useFake);
StringWriter sw = new StringWriter();
//kundenliste.WriteXml(sw);
XmlSerializer myserializer = new XmlSerializer(typeof(List<EntityInterface>));
xmlData = myserializer.ToString();
var stringwriter = new System.IO.StringWriter();
//var serializer = new XmlSerializer(this.GetType());
myserializer.Serialize(stringwriter, liste);
Console.WriteLine(stringwriter.ToString());
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(stringwriter.ToString());
long count = requestBytes.Length;
Response resp = new Response(request, request._socket);
resp.sendResponse(request.HttpVersion, getMIMEType(request.Url.Extension), (int)count, " 200 OK", requestBytes);
}
else if (temppath[2].StartsWith("edit"))
{
List<EntityInterface> liste = new List<EntityInterface>();
//StreamReader reader = new StreamReader(request.Header["xml"]);
//reader.ReadToEnd();
XmlReader reader = XmlReader.Create(new StringReader(request.Header["xml"]));
liste = (List<EntityInterface>)new XmlSerializer(typeof(List<EntityInterface>)).Deserialize(reader);
reader.Close();
string response = myBL.update(liste, request.Url.Parameter["from"]);
// was ASCII
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(response.ToString());
long count = requestBytes.Length;
Response resp = new Response(request, request._socket);
resp.sendResponse(request.HttpVersion, getMIMEType(request.Url.Extension), (int)count, " 200 OK", requestBytes);
}
else if (temppath[2].StartsWith("add"))
{
List<EntityInterface> liste = new List<EntityInterface>();
//StreamReader reader = new StreamReader(request.Header["xml"]);
//reader.ReadToEnd();
XmlReader reader = XmlReader.Create(new StringReader(request.Header["xml"]));
liste = (List<EntityInterface>)new XmlSerializer(typeof(List<EntityInterface>)).Deserialize(reader);
reader.Close();
////Console.WriteLine("switcher[1]:" + switcher[1]);
//Console.WriteLine("temü[2]:" + temppath);
string response = myBL.add(liste, request.Url.Parameter["from"]);
//was ASCII
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(response.ToString());
long count = requestBytes.Length;
Response resp = new Response(request, request._socket);
resp.sendResponse(request.HttpVersion, getMIMEType(request.Url.Extension), (int)count, " 200 OK", requestBytes);
}
else if (temppath[2].StartsWith("delete"))
{
List<EntityInterface> liste = new List<EntityInterface>();
//StreamReader reader = new StreamReader(request.Header["xml"]);
//reader.ReadToEnd();
XmlReader reader = XmlReader.Create(new StringReader(request.Header["xml"]));
liste = (List<EntityInterface>)new XmlSerializer(typeof(List<EntityInterface>)).Deserialize(reader);
reader.Close();
////Console.WriteLine("switcher[1]:" + switcher[1]);
//Console.WriteLine("temü[2]:" + temppath);
string response = myBL.delete(liste, request.Url.Parameter["from"]);
//was ASCII
byte[] requestBytes = System.Text.Encoding.UTF8.GetBytes(response.ToString());
long count = requestBytes.Length;
Response resp = new Response(request, request._socket);
resp.sendResponse(request.HttpVersion, getMIMEType(request.Url.Extension), (int)count, " 200 OK", requestBytes);
}
//return "ERROR parse " + temppath.Length.ToString() + " " + temppath[0];
}
//.........这里部分代码省略.........