Beispiel #1
0
        private void SetProperties()
        {
            _jClassInfo.Properties = new List <JInfo>();
            JClassCreater classCreater = new JClassCreater();
            JArrayCreater arrayCreater = new JArrayCreater();

            List <JToken> jTokens = _jObject.Values().ToList();

            foreach (var item in jTokens)
            {
                if (item.Type.ToString().Equals(JsonType.Object))
                {
                    JClassInfo temp = classCreater.Create((JObject)item);
                    temp.Parent = _jClassInfo;
                    //temp.Type = _jClassInfo.Name + (_jClassInfo.Properties.Count(x => x.Type == "class") + 1);

                    _jClassInfo.Properties.Add(temp);
                }
                else if (item.Type.ToString().Equals(JsonType.Array))
                {
                    JArray temp = (JArray)item;
                    _jClassInfo.Properties.Add(arrayCreater.Create(temp));
                }
                else
                {
                    _jClassInfo.Properties.Add(new JValueInfo
                    {
                        Name = Converter.PathToName(item.Path),
                        Type = Converter.TypeStringConverter(item.Type.ToString())
                    });
                }
            }
        }
Beispiel #2
0
        private void SetClassInfos()
        {
            var classes = (from x in _jArray.Children()
                           where x.Type.ToString() == JsonType.Object
                           select x).ToList();

            if (classes.Count == 0)
            {
                return;
            }

            JClassCreater classCreater = new JClassCreater();

            foreach (var x in classes)
            {
                JClassInfo tempInfo = classCreater.Create((JObject)x);
                tempInfo.Parent = _jArrayInfo;

                tempInfo.Type = _jArrayInfo.Name + (_jArrayInfo.ClassTypes.Count + 1);
                tempInfo.Name = "";

                if (!_jArrayInfo.ClassTypes.Contains(tempInfo))
                {
                    _jArrayInfo.ClassTypes.Add(tempInfo);
                }
            }

            if (_jArrayInfo.GenericType == SharpType.Class && _jArrayInfo.ClassTypes.Count == 1)
            {
                _jArrayInfo.GenericType = _jArrayInfo.ClassTypes[0].Type;
            }
            else
            {
                _jArrayInfo.GenericType = SharpType.Object;
            }
        }