Exemplo n.º 1
0
        public string Stringify()
        {
            JsonArray jsonArray = new JsonArray();
            foreach (School school in Education)
            {
                jsonArray.Add(school.ToJsonObject());
            }

            JsonObject jsonObject = new JsonObject();
            jsonObject[idKey] = JsonValue.CreateStringValue(Id);

            // Treating a blank string as null
            if (String.IsNullOrEmpty(Phone))
            {
                jsonObject[phoneKey] = JsonValue.CreateNullValue();
            }
            else
            {
                jsonObject[phoneKey] = JsonValue.CreateStringValue(Phone);
            }

            jsonObject[nameKey] = JsonValue.CreateStringValue(Name);
            jsonObject[educationKey] = jsonArray;
            jsonObject[timezoneKey] = JsonValue.CreateNumberValue(Timezone);
            jsonObject[verifiedKey] = JsonValue.CreateBooleanValue(Verified);

            return jsonObject.Stringify();
        }
Exemplo n.º 2
0
 public School(JsonObject jsonObject)
 {
     JsonObject schoolObject = jsonObject.GetNamedObject(schoolKey, null);
     if (schoolObject != null)
     {
         Id = schoolObject.GetNamedString(idKey, "");
         Name = schoolObject.GetNamedString(nameKey, "");
     }
     Type = jsonObject.GetNamedString(typeKey);
 }
Exemplo n.º 3
0
        public JsonObject ToJsonObject()
        {
            JsonObject schoolObject = new JsonObject();
            schoolObject.SetNamedValue(idKey, JsonValue.CreateStringValue(Id));
            schoolObject.SetNamedValue(nameKey, JsonValue.CreateStringValue(Name));

            JsonObject jsonObject = new JsonObject();
            jsonObject.SetNamedValue(schoolKey, schoolObject);
            jsonObject.SetNamedValue(typeKey, JsonValue.CreateStringValue(Type));

            return jsonObject;
        }
Exemplo n.º 4
0
        public string Stringify()
        {
            JsonArray jsonArray = new JsonArray();
            foreach (School school in Education)
            {
                jsonArray.Add(school.ToJsonObject());
            }

            JsonObject jsonObject = new JsonObject();
            jsonObject[idKey] = JsonValue.CreateStringValue(Id);
            jsonObject[nameKey] = JsonValue.CreateStringValue(Name);
            jsonObject[educationKey] = jsonArray;
            jsonObject[timezoneKey] = JsonValue.CreateNumberValue(Timezone);
            jsonObject[verifiedKey] = JsonValue.CreateBooleanValue(Verified);

            return jsonObject.Stringify();
        }
Exemplo n.º 5
0
 /// <summary>
 /// 将 Json.JsonObject 元素添加到 Json.JsonObject中
 /// </summary>
 /// <param name="json"></param>
 public void Add(JsonObject json)
 {
     Insert(null, json.ToString(), true);
 } 
Exemplo n.º 6
0
        /// <summary>
        /// 模型是对象,索引 对应是对象,返回 索引 对应的对象
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public JsonObject GetJson(int index)
        {
            if (isModel==false)
                return null;
            string subjson = base._GetCollection(this.rawjson)[index];
            if (subjson.Length < 2)
                return null;
            JsonObject model = new JsonObject(subjson);
            return model;
            /*
             * if (!model.isModel)
                return null;
            JsonObject submodel = new JsonObject(model.Value);

            if (!submodel.isModel)
                return null;
            else
                return submodel;
             * */
        }
Exemplo n.º 7
0
        public bool IsCollection(string key)
        {
            if (isModel==false)
                return false;

            if (string.IsNullOrEmpty(key))
                return false;

            foreach (string subjson in base._GetCollection(this.rawjson))
            {
                JsonObject model = new JsonObject(subjson);

                if (!model.isValue)
                    continue;

                if (model.Key == key)
                {
                    JsonObject submodel = new JsonObject(model.Value);

                    return submodel.isCollection;
                }
            }

            return false;
        }
Exemplo n.º 8
0
 private void listViewFriends_DoubleClick(object sender, EventArgs e)
 {
     //获得当前行
     int iRowCurr = this.listViewFriends.SelectedItems[0].Index;
     //取得当前行的数据
     string id = listViewFriends.SelectedItems[0].SubItems[1].Text;
     string userName = listViewFriends.SelectedItems[0].SubItems[2].Text;
     _farmStatus = GetFUserInfo(id,out dogJson);
     showFarmland(_farmStatus);
     showId = id;
     toLog("获取" + userName + "土地信息成功" );
     toStatus("当前显示农场为:" + userName + "的农场");
 }
Exemplo n.º 9
0
 /// <summary>
 /// 模型不是对象,返回 索引 对应的KEY
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 public string GetKey(int index)
 {
     if (isModel==false)
         return Key;
     string subjson = base._GetCollection(this.rawjson)[index];
     JsonObject model = new JsonObject(subjson);
     if (!model.isValue)
         return null;
     return model.Key;
 }
Exemplo n.º 10
0
 private void showFarmland(JsonObject farmStatus)
 {
     this.Invoke((MethodInvoker)delegate
     {
         listViewFarmland.Items.Clear();
     });
     string landStatus = "";
     string cropStatus = "";
     for (int i = 0; i < farmStatus.GetCollection().Count; i++)
     {
         ListViewItem lv = new ListViewItem();
         lv.SubItems[0].Text = i.ToString();
         Land newLand = new Land(farmStatus.GetCollection()[i]);
         CropItem newCropItem = new CropItem(GetCropModel(newLand.a));
         //lv.SubItems.Add(newLand.b.Equals("0") ? "空地":newShopItem.cName);
         landStatus = GetLandStatus(newLand, newCropItem);
         lv.SubItems.Add(landStatus);
         lv.SubItems.Add(newLand.f.Equals("0") ? "无" : newLand.f);
         lv.SubItems.Add(newLand.g.Equals("0") ? "无" : newLand.g);
         lv.SubItems.Add(newLand.h.Equals("0") ? "是" : "否");
         GetCropStatus(out cropStatus, newLand);
         lv.SubItems.Add(cropStatus);
         lv.SubItems.Add(TimeFormat.FormatTime((Convert.ToInt64(newLand.q) + Convert.ToInt64(newCropItem.growthCycle)).ToString()));
         this.Invoke((MethodInvoker)delegate
         {
             listViewFarmland.Items.Add(lv);
         });
     }
 }
 private void LoadFromJSON(JsonObject obj)
 {
     foreach (string key in obj.Keys)
     {
         switch (key)
         {
             case IdKey:
                 Id = obj.GetJSONContentAsInt(key);
                 break;
             case CustomerIdKey:
                 _customerId = obj.GetJSONContentAsInt(key);
                 break;
             case FirstNameKey:
                 FirstName = obj.GetJSONContentAsString(key);
                 break;
             case LastNameKey:
                 LastName = obj.GetJSONContentAsString(key);
                 break;
             case FullNumberKey:
                 FullNumber = obj.GetJSONContentAsString(key);
                 break;
             case ExpirationMonthKey:
                 ExpirationMonth = obj.GetJSONContentAsInt(key);
                 break;
             case ExpirationYearKey:
                 ExpirationYear = obj.GetJSONContentAsInt(key);
                 break;
             case CvvKey:
                 _cvv = obj.GetJSONContentAsString(key);
                 break;
             case BillingAddressKey:
                 BillingAddress = obj.GetJSONContentAsString(key);
                 break;
             case BillingAddress2Key:
                 BillingAddress2 = obj.GetJSONContentAsString(key);
                 break;
             case BillingCityKey:
                 BillingCity = obj.GetJSONContentAsString(key);
                 break;
             case BillingCountryKey:
                 BillingCountry = obj.GetJSONContentAsString(key);
                 break;
             case BillingStateKey:
                 BillingState = obj.GetJSONContentAsString(key);
                 break;
             case BillingZipKey:
                 BillingZip = obj.GetJSONContentAsString(key);
                 break;
             case BankNameKey:
                 _bankName = obj.GetJSONContentAsString(key);
                 break;
             case BankRoutingNumberKey:
                 _bankRoutingNumber = obj.GetJSONContentAsString(key);
                 break;
             case BankAccountNumberKey:
                 _bankAccountNumber = obj.GetJSONContentAsString(key);
                 break;
             case BankAccountTypeKey:
                 _bankAccountType = obj.GetJSONContentAsEnum<BankAccountType>(key);
                 break;
             case BankAccountHolderTypeKey:
                 _bankAccountHolderType = obj.GetJSONContentAsEnum<BankAccountHolderType>(key);
                 break;
             case PaymentMethodNonceKey:
                 _paymentMethodNonce = obj.GetJSONContentAsString(key);
                 break;
             case PayPalEmailKey:
                 _payPalEmail = obj.GetJSONContentAsString(key);
                 break;
             case PaymentTypeKey:
                 _paymentType = obj.GetJSONContentAsEnum<PaymentProfileType>(key);
                 break;
             case CardTypeKey:
                 _cardType = obj.GetJSONContentAsString(key);
                 break;
             case MaskedCardNumberKey:
                 _maskedCardNumber = obj.GetJSONContentAsString(key);
                 break;
             default:
                 break;
         }
     }
 }
Exemplo n.º 12
0
 private void btnDoAll_Click(object sender, EventArgs e)
 {
     btnDoAll.Enabled = false;
     LandHarvest(showId, _farmStatus);
     LandClearWeed(showId, _farmStatus);
     LandSpraying(showId, _farmStatus);
     LandWater(showId, _farmStatus);
     System.Threading.Thread.Sleep(2000);
     LandScaify(showId, _farmStatus);
     System.Threading.Thread.Sleep(2000);
     LandPlant(showId, _farmStatus);
     _farmStatus = GetFUserInfo(showId);
     showFarmland(_farmStatus);
     btnDoAll.Enabled = true;
 }
Exemplo n.º 13
0
 public Land(JsonObject farmStatus)
 {
     this._farmStatus = farmStatus;
 }
Exemplo n.º 14
0
 private void getBagInfo()
 {
     string url = runUrl + "/bbs/source/plugin/qqfarm/core/mync.php?mod=repertory&act=getUserSeed";
     //uIdx=19991&uinY=29991&farmTime=1298471523&farmKey=c69a093d8cd3e289c59b603b1a9d5db8
     string farmTime = FarmKey.GetFarmTime();
     string postData = "uIdx=" + uIdx + "&uinY=" + uinY + "&farmTime=" + farmTime + "&farmKey=" + FarmKey.GetFarmKey(farmTime, farmKeyEncodeString);
     string content = "";
     try
     {
         content = HttpChinese.GetHtml(postData, cookie, url);
     }
     catch (Exception except)
     {
         toLog(except.Message);
         toLog("背包信息获取失败");
     }
     _bagStatus = new JsonObject(content);
 }
Exemplo n.º 15
0
        private void GetFriends()
        {
            string url = "http://www.szshbs.com/bbs/source/plugin/qqfarm/core/mync.php?mod=friend";
            //string postData = "uinY=29991&farmKey=37a509272e0937f4075453bf9c30f9a4&uIdx=19991&farmTime=1298201167";
            string content = "";
            try
            {
                content = HttpChinese.GetHtml(cookie, url);
            }
            catch (Exception except)
            {
                toLog(except.Message);
                toLog("好友信息获取失败");
            }

            this._friends = new JsonObject(content);
        }
Exemplo n.º 16
0
 private void FrmFarm_Load(object sender, EventArgs e)
 {
     configApply();
     /*
     //读取_shop信息
     try
     {
         readShop();
     }
     catch (Exception)
     {
         _shop = new JsonObject(ScanShop());
         //保存_shop信息
         saveShop();
     }*/
     //读取_crop
     try
     {
         readCrop();
         toLog("读取植物信息成功");
     }
     catch (Exception)
     {
         try
         {
             readShop();
         }
         catch (Exception)
         {
             _shop = new JsonObject(ScanShop());
             //保存_shop信息
             saveShop();
         }
     }
     foreach(string key in _crop["种子"].Keys)
     {
         comboBoxAutoPlant.Items.Add(key);
     }
     CropItem tempCropItem = new CropItem(GetCropModel(cId));
     comboBoxAutoPlant.Text = tempCropItem.cName;
     threadGetFriends = new Thread(new ThreadStart(ListFriends));
     //ListFriends();
     threadGetUserInfo = new Thread(new ThreadStart(this.GetUserInfo));
     threadGetFriends.Start();
     threadGetUserInfo.Start();
     Thread threadGetBagInfo = new Thread(new ThreadStart(this.getBagInfo));
     threadGetBagInfo.Start();
     timer2.Enabled = false;
     timer1.Enabled = false;
     timer3.Enabled = true;
     //getUserInfo();
 }
Exemplo n.º 17
0
 private void btnWater_Click(object sender, EventArgs e)
 {
     btnWater.Enabled = false;
     LandWater(showId, _farmStatus);
     _farmStatus = GetFUserInfo(showId);
     showFarmland(_farmStatus);
     btnWater.Enabled = true;
 }
Exemplo n.º 18
0
 private void UserLandAuto()
 {
     if (_autoSteal)
     {
         LandHarvest(showId, _farmStatus);
     }
     if (_autoWeed)
     {
         LandClearWeed(showId, _farmStatus);
     }
     if (_autoWorm)
     {
         LandSpraying(showId, _farmStatus);
     }
     if (_autoWater)
     {
         LandWater(showId, _farmStatus);
     }
     System.Threading.Thread.Sleep(5000);
     if (_autoScarify)
     {
         LandScaify(showId, _farmStatus);
     }
     System.Threading.Thread.Sleep(5000);
     if (_autoPlant)
     {
         LandPlant(showId, _farmStatus);
     }
     _farmStatus = GetFUserInfo(showId);
     showFarmland(_farmStatus);
 }
Exemplo n.º 19
0
        /// <summary>
        /// 从 Json.JsonObject 中移除带有指定键的元素
        /// </summary>
        /// <param name="JsonObject"></param>
        public void Remove(JsonObject json)
        {
            if (isModel==false)
            {
                return;
            }
            int statsIndex = rawjson.IndexOf(json.ToString());//key的位置
            if (statsIndex < 0) return;
            string jsonq = rawjson.Substring(0, statsIndex);
            statsIndex = statsIndex + json.ToString().Length;//key的长度  加  :的长度 引号长度
            string jsonh = rawjson.Substring(statsIndex, rawjson.Length - statsIndex);
            bool requ = true;
            if (jsonh.StartsWith(",") && requ)
            {
                jsonh = jsonh.Substring(1);
                requ = false;
            }

            if (jsonq.EndsWith(",") && requ)
                jsonq = jsonq.Substring(0, jsonq.Length - 1);

            rawjson = jsonq + jsonh;
        }
Exemplo n.º 20
0
 public DoResult(string content)
 {
     this.resultInfo = new JsonObject(content);
 }
Exemplo n.º 21
0
 private void getFriendsFliter()
 {
     string farmTime = FarmKey.GetFarmTime();
     string farmKey = FarmKey.GetFarmKey(farmTime, farmKeyEncodeString);
     string url = runUrl + "/bbs/source/plugin/qqfarm/core/mync.php?mod=friend_1-3";
     //friend%5Fuins=177152%2C171380%2C170910%2C41131%2C51529%2C21212%2C178400%2C23587%2C173687%2C29991%2C97861%2C69758%2C176582%2C21895%2C47487%2C186460%2C53197%2C22445%2C193473%2C100125%2C44755%2C49155%2C94339%2C10728%2C79011%2C196379%2C42576%2C65975%2C25668%2C58280%2C198880%2C197733%2C110460%2C186528%2C22507%2C188238%2C68166
     //&farmKey=1fbdac99ce71af50c778e3987169f5b2&uIdx=19991&cmd=1
     //friend%5Fuids==167152%2C161380%2C160910%2C31131%2C41529%2C11212%2C168400%2C13587%2C163687%2C19991%2C87861%2C59758%2C166582%2C11895%2C37487%2C176460%2C43197%2C12445%2C183473%2C90125%2C34755%2C39155%2C84339%2C728%2C69011%2C186379%2C32576%2C55975%2C15668%2C48280%2C188880%2C187733%2C100460%2C176528%2C12507%2C178238%2C58166
     //&farmTime=1298479254&uinY=29991
     //
     //
     //string friend_Fuins = "friend_uins=177152,171380,170910,41131,51529,21212,178400,23587,173687,29991,97861,69758,176582,21895,47487,186460,53197,22445,193473,100125,44755,49155,94339,10728,79011,196379,42576,65975,25668,58280,198880,197733,110460,186528,22507,188238,68166";
     string friend_Fuins = _friendsUInX;
     friend_Fuins = "friend%5Fuins=" + HttpUtility.UrlEncode(friend_Fuins);
     //string friend_Fuids = "friend_uids=161380,167152,160910,31131,41529,11212,168400,13587,163687,87861,59758,11895,166582,37487,176460,19991,43197,183473,12445,34755,39155,90125,84339,728,69011,186379,55975,32576,15668,48280,100460,187733,178238,12507,58166";
     string friend_Fuids = _friendsIds;
     friend_Fuids = "friend%5Fuids=" + HttpUtility.UrlEncode(friend_Fuids);
     string postData = "uIdx=" + uIdx + "&uinY=" + uinY + "&farmTime=" + farmTime + "&farmKey=" + farmKey + "&cmd=1" + "&" + friend_Fuins + "&" + friend_Fuids;
     //
     //
     string content = "";
     try{
         content = HttpChinese.GetHtml(postData, cookie, url);
         _friendsFliter = new JsonObject(content).GetJson("status");
     }
     catch(Exception except)
     {
         toLog(except.Message);
         toLog("可摘取好友信息获取失败");
     }
 }
Exemplo n.º 22
0
 private void readShop()
 {
     try
     {
         IFormatter formatter = new BinaryFormatter();
         Stream readStream = new FileStream("shop.bin", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
         _shop = (JsonObject)formatter.Deserialize(readStream);
         readStream.Close();
     }
     catch (Exception except)
     {
         throw except;
     }
 }
Exemplo n.º 23
0
 public DoStatus(JsonObject doStatusInfo)
 {
     this.doStatusInfo = doStatusInfo;
 }
Exemplo n.º 24
0
 private JsonObject GetFUserInfo(string id, out JsonObject dogJson)
 {
     string url = "http://www.szshbs.com/bbs/source/plugin/qqfarm/core/mync.php?mod=user&act=run";
     //string postData = "ownerId=161380&uinY=29991&uIdx=19991&uinX=171380&farmTime=1298272127&farmKey=b52a85425816b04fbe2cd96830ef0e89";
     //ownerId  : 好友ID
     //uinX 	:猜测是牧场ID,可从user的uinLogin获得
     //uIdx	:自己的ID
     //uinY	:可从user的uinLogin获得
     string ownerId = id;
     User _friendInfo = new User(GetUserModel(id));
     string uinX = _friendInfo.uin;
     string farmTime = FarmKey.GetFarmTime();
     string postData = "ownerId=" + ownerId + "&uinY=" + uinY + "&uIdx=" + uIdx
         + "&uinX=" + uinX + "&farmTime=" + farmTime + "&farmKey=" + FarmKey.GetFarmKey(farmTime, farmKeyEncodeString);
     string content = "";
     JsonObject tempJson = new JsonObject();
     try
     {
         content = HttpChinese.GetHtml(postData, cookie, url);
         JsonObject farmJson = new JsonObject(content);
         tempJson = new JsonObject(farmJson.GetValue("farmlandStatus"));
         dogJson = new JsonObject(farmJson.GetValue("dog"));
     }
     catch (Exception except)
     {
         toLog(except.Message);
         toLog("指定用户信息获取失败");
         dogJson = new JsonObject();
     }
     return new JsonObject(tempJson);
 }
Exemplo n.º 25
0
 public User(JsonObject user)
 {
     this.user = user;
 }
Exemplo n.º 26
0
 private void GetUserInfo()
 {
     string url = "http://www.szshbs.com/bbs/source/plugin/qqfarm/core/mync.php?mod=user&act=run";
     string content = "";
     try
     {
         content = HttpChinese.GetHtml(cookie, url);
         this._status = new JsonObject(content);
         uName = _status.GetJson("user").GetValue("userName");
         uIdx = _status.GetJson("user").GetValue("uId");
         uinY = _status.GetJson("user").GetValue("uinLogin");
         model = _status;
         string headPic = model.GetJson("user").GetValue("headPic");
         int level = 0;
         string exp = "";
         exp = _status.GetJson("user").GetValue("exp");
         exp = FormatExp(Convert.ToInt32(exp), out level);
         //读取头像可能出现没有头像的结果,导致一直等待
         if (uIdx.Equals("19991"))
         {
             if (headPic != null)
             {
                 try
                 {
                     Stream stream = HttpChinese.GetStream(headPic, cookie);
                     picHead.Image = Image.FromStream(stream);
                 }
                 catch (Exception e)
                 {
                     toLog(e.Message);
                 }
             }
         }
         this.Invoke((MethodInvoker)delegate
         {
             lblUserName.Text = _status.GetJson("user").GetValue("userName");
             lblMoney.Text = _status.GetJson("user").GetValue("money");
             lblExp.Text = exp;
             lblLevel.Text = level.ToString();
         });
         toLog("获取用户信息成功");
         //以下获得农场信息
         _farmStatus = new JsonObject(_status.GetValue("farmlandStatus"));
         dogJson = new JsonObject(_status.GetValue("dog"));
         showFarmland(_farmStatus);
         showId = uIdx;
         toLog("获得用户土地信息成功");
         toStatus("当前显示农场为" + uName + "的农场");
     }
     catch (Exception except)
     {
         toLog(except.Message);
         toLog("用户信息获取失败");
     }
 }
 public PaymentProfileView(JsonObject PaymentProfileObject) : base()
 {
     if (PaymentProfileObject == null) throw new ArgumentNullException("PaymentProfileObject");
     if (PaymentProfileObject.Keys.Count <= 0) throw new ArgumentException("Not a vaild PaymentProfile node", "PaymentProfileObject");
     this.LoadFromJSON(PaymentProfileObject);
 }
Exemplo n.º 28
0
        /// <summary> 
        /// 当模型是对象,返回拥有的key 
        /// </summary> 
        /// <returns></returns> 
        public List<string> GetKeys()
        {
            if (isModel==false)
                return null;

            List<string> list = new List<string>();

            foreach (string subjson in base._GetCollection(this.rawjson))
            {
                string key = new JsonObject(subjson).Key;

                if (!string.IsNullOrEmpty(key))
                    list.Add(key);
            }

            return list;
        } 
Exemplo n.º 29
0
        /// <summary>
        /// Converts JsonML in object form to XML.
        /// </summary>

        public static void DecodeObjectForm(JsonReader reader, XmlWriter writer)
        {
            if (reader == null) throw new ArgumentNullException("reader");
            if (writer == null) throw new ArgumentNullException("writer");

            reader.ReadToken(JsonTokenClass.Object);

            string tagName = null;
            JsonObject attributes = null;
            JsonRecorder childNodes = null;
            ArrayList childNodesList = null;
            
            while (reader.TokenClass != JsonTokenClass.EndObject)
            {
                string memberName = reader.ReadMember();
                
                switch (memberName)
                {
                    case "tagName":
                    {
                        if (tagName != null && string.CompareOrdinal(reader.Text, tagName) != 0)
                            throw new JsonMLException("Tag name already defined.");
                        tagName = reader.Text;
                        if (tagName.Length == 0)
                            throw new JsonMLException("Tag name cannot be empty.");
                        reader.Read();
                        break;
                    }
                    case "childNodes":
                    {
                        if (reader.TokenClass == JsonTokenClass.Null)
                        {
                            reader.Read();
                        }
                        else
                        {
                            if (reader.TokenClass != JsonTokenClass.Array)
                                throw new JsonMLException("Child nodes must be a JSON array.");
                            
                            JsonRecorder aChildNodes = new JsonRecorder();
                            aChildNodes.WriteFromReader(reader);
                            if (childNodes == null)
                            {
                                childNodes = aChildNodes;
                            }
                            else
                            {
                                if (childNodesList == null)
                                    childNodesList = new ArrayList(4);
                                childNodesList.Add(aChildNodes);
                            }
                        }
                        break;
                    }
                    default:
                    {
                        if (attributes == null)
                            attributes = new JsonObject();
                        if (reader.TokenClass == JsonTokenClass.Array || reader.TokenClass == JsonTokenClass.Object)
                            throw new JsonMLException("Non-scalar attribute value.");
                        if (reader.TokenClass != JsonTokenClass.Null)
                            attributes.Add(memberName, reader.Text);
                        reader.Read();
                        break;
                    }
                }
            }

            reader.Read();

            if (tagName == null && writer.WriteState != WriteState.Element && writer.WriteState != WriteState.Content)
                throw new JsonMLException("Tag name not found.");

            writer.WriteStartElement(tagName);

            if (attributes != null)
            {
                foreach (JsonMember attribute in attributes)
                    writer.WriteAttributeString(attribute.Name, attribute.Value.ToString());
            }

            DecodeChildNodes(childNodes, writer);

            if (childNodesList != null)
            {
                foreach (JsonRecorder aChildNodes in childNodesList)
                    DecodeChildNodes(aChildNodes, writer);
            }

            writer.WriteEndElement();
        }
Exemplo n.º 30
0
        /// <summary> 
        /// 当模型是对象,key对应是值,则返回key对应的值 
        /// </summary> 
        /// <param name="key"></param> 
        /// <returns></returns> 
        public string GetValue(string key)
        {
            if (isModel==false)
                return null;

            if (string.IsNullOrEmpty(key))
                return null;

            foreach (string subjson in base._GetCollection(this.rawjson))
            {
                JsonObject model = new JsonObject(subjson);

                if (!model.isValue)
                    continue;

                if (model.Key == key)
                    return model.Value;
            }

            return null;
        }