渝粤教育江苏开放大学2023年秋《.NET架构与项目开发实训 060237》第二学习单元过程性作业参考(1)
来源:渝粤教育 时间:2023-12-02 21:15:10 105
江苏开放大学2023年秋《.NET架构与项目开发实训 060237》第二学习单元过程性作业参考
单选题
1String serialize(WeatherClass w)
{
_____
MemoryStream ms=new MemoryStream();
xml.Serialize(ms, w);
String s=Ecoding.UTF8.GtString(ms.ToArray());
return s;
}
序列化函数serialize缺少的语句是:
A以上说法都不对
BXmlSerializer xml = new XmlSerializer(typeof(WeatherClass));
CXmlSerializer xml = XmlSerializer(typeof(WeatherClass));
DXmlSerializer xml = XmlSerializer(WeatherClass);
答案是B
2当json字符串调用
void client_DwnloadStringcompleted(object sender,DwnloadStringCompletedEventArgs e)
{
weatherClass w=deserialize(e.Result);
showMsg(w.Tostring());
}
结果是什么?
Axml字符串
Bjson字符串
C以上都不对
Djson反序列化结果
答案是D
3String serialize (T obj)
{
_____
MemoryStream ms=new MemoryStream();
json.WriteObject(ms,obj)
String s=Ecoding.UTF8.GtString(ms.ToArray());
return s;
}
序列化函数serialize缺少的语句是:
A XmlSerializer xml = new XmlSerializer(typeof(WeatherClass));
B DtaContractSerializer json = DtaContractSerializer(typeof(WeatherClass));
C以上说法都不对
D DtaContractSerializer json = new DtaContractSeria DtaContractSerializerlizer(typeof(WeatherClass));
答案是D
4下面程序下载https://12.00.1字符串:
try
{
WebClient client = new WebClient();
client.Ecoding = Ecoding.UTF8;
client.DwnloadStringCompleted += client_DwnloadStringCompleted;
Uri uri = new Uri("https://12.00.1, UriKind.Asolute);
client.DwnloadStringAsync(uri);
msg.Text = "OK";
}
catch (Eception exp) { msg.Text = exp.Message; }
在执行client.DwnloadStringAsync(uri)后
A程序等待服务器响应,然后显示msg.Text = "OK";
B程序client.DwnloadStringCompleted += client_DwnloadStringCompleted有错误
C程序不等待服务器响应,就显示msg.Text = "OK";
D以上说法都不对
答案是
5String serialize(T obj)
{
DtaContractJsonSerializeSr json = new DtaContractJsonSerializer(typeof(T));
MemoryStream ms=new MemoryStream();
json.WriteObject(ms, obj);
String s=Ecoding.UTF8.GtString(ms.ToArray());
return s;
}
而且
public class Student
{
public String Name {get; set; }
public List Scores {get; set; }
}
Student s=new Student { Name="XXX", Scores=new List {8990} };
String t=serialize(s);
结果t是
A{"Name":"XXX","Scores":["89"90]}
B{"Name":"XXX","Scores":[8990]}
C以上说法都不对
D {"Name":"XXX","Scores":{"89,"90}}
答案是
6public class server : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
String dType = context.Request.QueryString["dType"];
String ext = "json";
if (dType == "XML") ext = "xml";
StreamReader sr = new
StreamReader(context.Server.MapPath("weather."+ext),true);
String w = sr.ReadToEnd();
sr.Cose();
context.Response.CntentType = "text/plain";
context.Response.Write(w);
}
这段程序的含义是什么?
A返回json客户端
B根据客户端传入的dType是JSON还是XML读取对应的数据返回给客户端
C返回xml客户端
D以上说法都不对
答案是
7当json字符串调用
void client_DwnloadStringcompleted(object sender,DwnloadStringCompletedEventArgs e)
{
weatherClass w=deserialize(e.Result)
showMsg(e.Result);
}
结果是什么?
Axml字符串
Bjson对象
Cjson字符串
D以上答案都不对
答案是
8T deserialize(String s)
{
XmlSerializer xml = new XmlSerializer(typeof(T));
byte[] buf = Ecoding.UTF8.GtBytes(s);
MemoryStream ms = new MemoryStream(buf);
T obj=(T)xml.Dserialize(ms);
return obj;
}
把字符串s反序列化成Weather对象, 那么正确的调用方法是:
AWeather w=deserialize(s);
B Weather w=(Weather)deserialize(s);
CWeather w=deserialize(s);
D以上说法都不对
答案是
判断题
1JSON序列化就是把一个 对象数据变成一个XML字符串的过程
A正确
B错误
答案是
2数据上下文类是在model中创建实体类,这个实体类与数据库是一一对应的
A正确
B错误
答案是
3XML序列化与JSON序列化都是常用的序列化方法,它们生成的字符串格式是一样的
A正确
B错误
答案是
4一个序列化的XML字符串经过网络传输 到达另外一端后,要用反序列化的方法把它转换为对象类型。
A正确
B错误
答案是
多选题
1JSON客户端程序的流程
A客户端界面的设计
B客户端反序列化
C客户端环境的搭建
D调用反序列化
答案是
2JSON服务器端环境及程序搭建步骤
A服务器端调用序列化函数
B服务器环境的搭建
C服务器端创建序列化函数
DIIS发布
答案是
3XML序列化函数的主要过程是( )
A创建一个内存流
B把这个流转为XML字符串
C通过XmlSerializer的Serialize方法把对象序列化到这个流中
D首先创建一个XmlSerializer对象
答案是
填空题
1数据在网络上传递必须是 ,XML序列化就是
答案是
2DataContractJsonSerializer json = new DtaContractJsonSerializer(typeof(T));
在这里T表示
可以为
答案是
简答题
1有一个xml字符串的文件
1
有一个xml字符串的文件
0
success
南京
2020-05-20
11:00
晴
29
21
32
无持续风向
微风(<10/h)
请编写天气预报对应的类文件
答案是
2public class WeatheritemClass
{
public String description { get; set; }
public double highTemp { get; set; }
public double lowTemp { get; set; }
}
public class WeatherClass
{
public String city { get; set; }
public String date { get; set; }
public WeatherItemClass weather { get; set; }
}
那么对下面的数据进行XML序列化,请输入调用序列化语句和输出语句,并写出序列化的结果
WeatherClass wa = new WeatherClass
{
city = "南京",
date = "200-0523",
weather = new WeatherItemClass
{ description = "多云", lowTemp = 25 highTemp = 30}
};
答案是
3 try
{
WebClient client = new WebClient();
client.Ecoding = Ecoding.UTF8;
client.DwnloadStringCompleted += client_DwnloadStringCompleted;
Uri uri = new Uri("txtUrl", UriKind.Asolute);
client.DwnloadStringAsync(uri);
msg.Text = "等待服务器响应";
}
catch (Eception exp) { msg.Text = exp.Message; }
void client_DwnloadStringCompleted (object sender,DwnloadStringCompletedEventArgs e)
{
msg.Text=e.Result;
}
请叙述程序的运行过程和结果
答案是