public CascadeRelationDataResource()
        {
            string strJson = "";

            FileTool.ReadFile(@"TestJson\Graduation.Json", ref strJson);
            cGraduation          = Json_Operation.JsonToObject <CGraduation>(strJson);
            cData_NumOfWires     = new CData_NumOfWires();
            m_TransducerSelected = cGraduation.listTransducers[0];
            m_SubTypeSelected    = cGraduation.listTransducers[0].listSubType[0];
            m_UnitSelected       = cGraduation.listTransducers[0].listSubType[0].listUnit[0];
            m_NumOfWiresSelected = cData_NumOfWires.listNumOfWires[0];

            OnParameterChanged();
        }
Ejemplo n.º 2
0
        public JsonFileOperation1()
        {
            InitializeComponent();

            //1.对象-->JSON
            UserInfo info = new UserInfo
            {
                Age      = 10,
                Gender   = 1,
                UserName = "******",
                Lover    = new List <string> {
                    "美女1", "美女2", "美女3"
                },
                Address = new ContactAddress
                {
                    Province = "湖南省",
                    City     = "长沙市",
                    Country  = "望城县",
                    Details  = "某旮旯快递找不到的地方"
                },
                DailyRecord = new Dictionary <string, string> {
                    { "星期一", "吃饭" }, { "星期二", "洗衣服" }, { "星期三", "好事情" }
                }
            };

            string json = Json_Operation.ObjectToJSON <UserInfo>(info);

            FileTool.WriteFile(@"TestJson\TuserInfo.json", json);

            string refstring = null;

            FileTool.ReadFile(@"TestJson\TuserInfo.json", ref refstring);

            UserInfo uI = Json_Operation.JsonToObject <UserInfo>(refstring);

            uI.Age = 100;

            FileTool.WriteFile(@"TestJson\T.json", Json_Operation.ObjectToJSON <UserInfo>(uI));
        }