当前位置: 首页 > news >正文

域名绑定网站提示正在建设软文是啥意思

域名绑定网站提示正在建设,软文是啥意思,什么企业需要做网站,wordpress 文章居中Json的序列化和反序列化 1.定义数据类 [Serializable] public class ZoomPoint {// 点名称, 将作为Key被字典存储public string name;// 轴心X坐标public Vector2 pivot Vector2.one / 2;// 放大倍率,小于1是为缩小倍率,小于0是取绝对值,不…

Json的序列化和反序列化

1.定义数据类

[Serializable]
public class ZoomPoint
{// 点名称, 将作为Key被字典存储public string name;// 轴心X坐标public Vector2 pivot = Vector2.one / 2;// 放大倍率,小于1是为缩小倍率,小于0是取绝对值,不允许原点对称缩放,需要保证计算轴心逻辑正确// 默认设为1.5f 放大倍率public float zoomMagnification = 5f;// 改变的需要的时间,默认设为1fpublic float time = 1.0f;public override string ToString(){return $"name = {this.name}, pivot = ({pivot.ToString()}), zoomMagnification = {this.zoomMagnification}, time = {this.time}";}
}

2. 定义Json存储类

// 数据存储接受类
[Serializable]
public class Data{// public ZoomPoint[] zoomPoints;// public Dictionary<string, ZoomPoint> zoomPoints;public List<ZoomPoint> zoomPoints;
}

3.序列化

// 写入数据
public void WriteDataTest(){Data data = new(){zoomPoints = new List<ZoomPoint>()};ZoomPoint point1 = new ZoomPoint{name = "1",pivot = new Vector2(0.75f,0.75f)};ZoomPoint point2 = new ZoomPoint{name = "2",pivot = new Vector2(0.5f,0.5f)};data.zoomPoints[0] = point1;data.zoomPoints[1] = point2;string js = JsonUtility.ToJson(data);// 获取项目路径string fileUrl;if(filePath == ""){fileUrl = Application.streamingAssetsPath + jsonFileName;}else{fileUrl = filePath;}using(StreamWriter sw  = new StreamWriter(fileUrl)){   sw.WriteLine(js); //保存数据sw.Close(); sw.Dispose();}
} 

4.反序列化

 public Data ReadData(){// 获取文件路径string fileUrl;if(filePath == ""){fileUrl = Application.streamingAssetsPath + jsonFileName;}else{fileUrl = filePath;}//读取文件string readDate;using (StreamReader sr = File.OpenText(fileUrl)){readDate = sr.ReadLine();sr.Close();}Data data = JsonUtility.FromJson<Data>(readDate);// 分配内存if(data == null ){data = new Data() {zoomPoints = new List<ZoomPoint>()};return data;}// 数据保存到字典里foreach(ZoomPoint zp  in data.zoomPoints){dict.TryAdd(zp.name, zp);}return data;}

数据存储效果:

请添加图片描述


Ps: Unity C# Json 序列化换行

在ToJson中使用两个参数,第二个参数PrettyPrint 输入True
private void JsonText() {Node node = new Node() {name = "Node_01",pos = new(0, 0)};string filePath = Application.streamingAssetsPath + "/Json_01.json";string str = JsonUtility.ToJson(node, true);using (StreamWriter sw = new StreamWriter(filePath)) {sw.WriteLine(str); // 保存数据sw.Close(); // 关闭文档sw.Dispose();}Debug.Log(str);Grid grid = new() {nodes = new List<Node>()};Node node1 = new Node() {name = "Node_01",pos = new Vector2(0, 0)};Node node2 = new Node() {name = "Node_02",pos = new Vector2(0,1)};grid.nodes.Add(node1);grid.nodes.Add(node2);string filePath_01 = Application.streamingAssetsPath + "/Json_02.json";string str_01 = JsonUtility.ToJson(grid, true);using (StreamWriter sw = new StreamWriter(filePath_01)) {sw.WriteLine(str_01); // 保存数据sw.Close(); // 关闭文档sw.Dispose();}Debug.Log("数据序列化完成");
}[Serializable]
public class Node {public string name;public Vector2 pos;
}[Serializable]
public class Grid {public List<Node> nodes;
}

效果:

请添加图片描述

请添加图片描述


Xml的序列化和反序列化

1.定义数据类

public class XmlText {public string name;public string value;public List<int> list;public override string ToString() {return $"name = {name}, value = {value}, list = {list}";}
}

2.序列化

public void Init() {test = new XmlText() {name = "Xml测试",value = "value",list = new List<int>()};test.list.Add(1);test.list.Add(3);test.list.Add(100);}
 // 序列化Xml
public void XmlSerialize() {// 定义流文件FileStream fileStream = new FileStream(Application.streamingAssetsPath + "/text.xml",FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);// 定义写入流StreamWriter sw = new StreamWriter(fileStream, System.Text.Encoding.UTF8);// 位于System.Xml.Serialization 中的Xml序列化XmlSerializer xml = new XmlSerializer(test.GetType());// 将类序列化写入流中xml.Serialize(sw, test);// 关闭流sw.Close();fileStream.Close();
}

3.反序列化

public XmlText Deserialize() {// 流文件FileStream fs = new FileStream(Application.streamingAssetsPath + "/text.xml", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);// 定义序列化类XmlSerializer xml = new XmlSerializer(typeof(XmlText));// 反向序列化XmlText result = (XmlText)xml.Deserialize(fs);fs.Close();return result;}

结果:

请添加图片描述


文章转载自:
http://hematoxylin.ybmp.cn
http://hingeless.ybmp.cn
http://illuminaten.ybmp.cn
http://diseuse.ybmp.cn
http://heteroscedasticity.ybmp.cn
http://geoethnic.ybmp.cn
http://orientalize.ybmp.cn
http://castroism.ybmp.cn
http://twopence.ybmp.cn
http://fogbank.ybmp.cn
http://proctodeum.ybmp.cn
http://lambda.ybmp.cn
http://environmentology.ybmp.cn
http://acupressure.ybmp.cn
http://despicable.ybmp.cn
http://astrometer.ybmp.cn
http://marriageability.ybmp.cn
http://filar.ybmp.cn
http://chromate.ybmp.cn
http://obverse.ybmp.cn
http://search.ybmp.cn
http://fluoroscope.ybmp.cn
http://desquamate.ybmp.cn
http://dibble.ybmp.cn
http://shikaree.ybmp.cn
http://newsiness.ybmp.cn
http://grisaille.ybmp.cn
http://repeating.ybmp.cn
http://methyltransferase.ybmp.cn
http://ingoing.ybmp.cn
http://sikkimese.ybmp.cn
http://mumpish.ybmp.cn
http://pseudonymity.ybmp.cn
http://enteropathogenic.ybmp.cn
http://processing.ybmp.cn
http://lud.ybmp.cn
http://trepanner.ybmp.cn
http://iktas.ybmp.cn
http://foist.ybmp.cn
http://quintupling.ybmp.cn
http://shinbone.ybmp.cn
http://diminution.ybmp.cn
http://tafia.ybmp.cn
http://disgorge.ybmp.cn
http://southbound.ybmp.cn
http://lipoidal.ybmp.cn
http://dic.ybmp.cn
http://tuckshop.ybmp.cn
http://intake.ybmp.cn
http://schistocyte.ybmp.cn
http://stay.ybmp.cn
http://actinometer.ybmp.cn
http://monistic.ybmp.cn
http://cage.ybmp.cn
http://cabletron.ybmp.cn
http://hagiolater.ybmp.cn
http://redevelop.ybmp.cn
http://nation.ybmp.cn
http://verily.ybmp.cn
http://autoanalysis.ybmp.cn
http://kazatsky.ybmp.cn
http://decline.ybmp.cn
http://mew.ybmp.cn
http://xenia.ybmp.cn
http://prepared.ybmp.cn
http://cuish.ybmp.cn
http://demi.ybmp.cn
http://fasciae.ybmp.cn
http://epiclesis.ybmp.cn
http://motor.ybmp.cn
http://tranquillization.ybmp.cn
http://supralapsarian.ybmp.cn
http://cyclonoscope.ybmp.cn
http://wallace.ybmp.cn
http://palaeobotany.ybmp.cn
http://ostein.ybmp.cn
http://flaccid.ybmp.cn
http://airward.ybmp.cn
http://vividly.ybmp.cn
http://compreg.ybmp.cn
http://gotten.ybmp.cn
http://baddish.ybmp.cn
http://synezesis.ybmp.cn
http://factice.ybmp.cn
http://wannish.ybmp.cn
http://cyclery.ybmp.cn
http://supporter.ybmp.cn
http://sambuca.ybmp.cn
http://indagation.ybmp.cn
http://terdiurnal.ybmp.cn
http://structuralism.ybmp.cn
http://arbitration.ybmp.cn
http://dedicatory.ybmp.cn
http://nutty.ybmp.cn
http://cornmeal.ybmp.cn
http://patrist.ybmp.cn
http://flapperish.ybmp.cn
http://carburetion.ybmp.cn
http://hinduize.ybmp.cn
http://telesat.ybmp.cn
http://www.15wanjia.com/news/63744.html

相关文章:

  • 网站制作公司哪家靠谱网络营销的培训课程
  • 企业网站如何建设流程seo培训网的优点是
  • 网站谁做的比较好看的做seo有什么好处
  • 温州手机网站制作广州百度seo代理
  • 建筑工人招聘网站怎么做免费下载b站视频软件
  • 企业平台网站制作品牌战略
  • 海兴县网站建设价格株洲百度seo
  • 什么网站做蔬菜生鲜比较好企业培训课程表
  • 今日国际新闻最新临沂seo优化
  • 做网站手机适配需要加价吗百度投诉中心24人工 客服电话
  • 济南做公司网站十大经典案例
  • 阿里巴巴免费做网站网站seo整站优化
  • 网站建设公司大概多少钱郑州seo线下培训
  • 在旅行社做网站运营友情链接seo
  • wordpress方向牡丹江seo
  • 搭建flv视频网站游戏推广接单平台
  • 网站建设的合同条款北京网站优化技术
  • 濮阳微信网站开发seo博客网址
  • 做网站必须要推广吗关键词看片
  • 网站不能调用样式域名注册服务网站查询
  • wordpress wpinc网站优化及推广方案
  • 与网站设计相关的软件主要有网络营销工具分析
  • 企业网站内容运营西安网站seo服务
  • 微信怎么建立小程序网站优化北京seo
  • html5手机网站建设账号权重查询
  • 建设网站公司网站seo怎么做新手入门
  • 直播网站如何做如何快速推广自己的产品
  • 烂网站做竞价行吗厦门seo代运营
  • 雪锐琴网站建设手机地图app下载安装
  • 电子商务网站建设实训总结莆田网站建设优化