Exemplo n.º 1
0
        private void BtnTestData002_Load_Click(object sender, EventArgs e)
        {
            //파일 읽기
            string sJson = File.ReadAllText(@"TestData002.json");
            //json문자열을 모델로 변환
            TestData002 tdTemp = JsonConvert.DeserializeObject <TestData002>(sJson);

            txtDoubleData.Text    = tdTemp.DoubleData.ToString();
            txtFloatData.Text     = tdTemp.FloatData.ToString();
            numericTypeTest1.Text = ((int)tdTemp.TypeTest1).ToString();
            numericTypeTest2.Text = ((int)tdTemp.TypeTest2).ToString();
        }
Exemplo n.º 2
0
        private void BtnTestData002_Save_Click(object sender, EventArgs e)
        {
            TestData002 tdTemp = new TestData002();

            tdTemp.DoubleData = Convert.ToDouble(txtDoubleData.Text);
            tdTemp.FloatData  = (float)Convert.ToDouble(txtFloatData.Text);
            tdTemp.TypeTest1  = (Test1Type)Convert.ToInt32(numericTypeTest1.Text);
            tdTemp.TypeTest2  = (Test2Type)Convert.ToInt32(numericTypeTest2.Text);

            //모델을 json 문자열로 변환
            string sJson = JsonConvert.SerializeObject(tdTemp);

            //파일로 저장
            File.WriteAllText(@"TestData002.json", sJson);
        }