private void usc_Input_GenerateButtonClicked(object sender, Controls.GenerateButtonClickedEventArgs e) { JObject jObject; try { jObject = JObject.Parse(e.JsonString); } catch (Exception exception) { MessageBox.Show("json object 생성중에 예외 발생\n" + exception.Message, "알림"); return; }; JClassInfo temp = _jClassCreater.Create(jObject); ClassInfoTreeNode classInfoTreeNode = new ClassInfoTreeNode(temp); _declareOption = e.SelectedOption; _formatString = e.FormatString; SetNode(classInfoTreeNode); usc_CodeViewer.ClearTreeView(); usc_CodeViewer.AddNode(classInfoTreeNode); usc_CodeViewer.SetCodeText(classInfoTreeNode.ClassCode); }
static void Main(string[] args) { //string json = TempStringReader.GetJsonString("../../../samplej.txt"); //JToken jo = JToken.Parse(json); //Console.WriteLine(jo.Type); //JToken jt1 = jo[0]; //JToken jt4 = jo[3]; //Console.WriteLine(jt4.Count()); //JObject jo1 = (JObject)jo[0]; //JObject jo2 = (JObject)jo[1]; //JObject jo3 = (JObject)jo[2]; //JObject jo4 = (JObject)jo[3]; //List<string> jpn1 = (from p in jo1.Properties() // select p.Name).ToList(); //List<string> jpn2 = (from p in jo2.Properties() // select p.Name).ToList(); //List<string> jpn3 = (from p in jo3.Properties() // select p.Name).ToList(); //List<string> jpn4 = (from p in jo4.Properties() // select p.Name).ToList(); //Console.WriteLine(jpn1.Intersect(jpn2).Count() == jpn1.Count); //Console.WriteLine(jpn1.Intersect(jpn3).Count() == jpn1.Count); //Console.WriteLine(jpn4.Count); string str = TempStringReader.GetJsonString("../../../samplej2.txt"); JObject jObject = JObject.Parse(str); JClassCreater jCreator = new JClassCreater(); JClassInfo jClassInfo = jCreator.Create(jObject); foreach (var item in jClassInfo.Properties) { Console.WriteLine(item); } Console.WriteLine(); foreach (var property in ((JClassInfo)jClassInfo.Properties[2]).Properties) { Console.WriteLine(property); } //JArray jArray = JArray.Parse(str); //JArrayCreater jArrayCreater = new JArrayCreater(); //jArrayCreater.Create(jArray); Console.WriteLine(); JValueInfo v1 = new JValueInfo { Name = "name", Type = "string" }; JValueInfo v2 = new JValueInfo { Name = "name", Type = "string" }; Console.WriteLine(v1.Equals(v2)); JClassInfo c1 = new JClassInfo { Name = "c1", Type = "class", Properties = new List <JInfo>() }; c1.Properties.Add(v1); JClassInfo c2 = new JClassInfo { Name = "c1", Type = "class", Properties = new List <JInfo>() }; c2.Properties.Add(v2); Console.WriteLine(c1.Equals(c2)); }