Advertisement
vinedfs

Leitura

Dec 22nd, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. public SFS2XItemAttrib[] GetSFS2XItemAttribFromJSON(string input) {
  2.         if (input [0] == '"') {
  3.             input = ReviseJSONResponse (input);
  4.         }
  5.         JSONNode response = JSON.Parse (input);
  6.         JSONNode data = null;
  7.         try {
  8.             data = JSON.Parse (response ["itens"].ToString ());
  9.         } catch (Exception e) {
  10.             Log ("Exception: " + e.ToString());
  11.             Log ("Input: " + input);
  12.             WindowAlert.Show ("Erro na leitura", "Não foi possível ler as informações vindas do banco de dados, isso pode ter ocorrido devido a alguma inconsistência nos dados, por favor, entre em contato o nosso suporte.", delegate {
  13.                 SFS2XManager.Instance.SetState(SFS2XManager.STATE_LOGOUT_REQUEST);
  14.                 SFS2XManager.Instance.Disconnect();
  15.             });
  16.             return null;
  17.         }
  18.         SFS2XItemAttrib[] acquiredItemsReceived = new SFS2XItemAttrib[data.Count];
  19.         for (int i = 0; i < data.Count; i ++) {
  20.             try {
  21.                 acquiredItemsReceived[i] = new SFS2XItemAttrib(int.Parse(data[i]["id"]), int.Parse(data[i]["color"]));
  22.             } catch (Exception e) {
  23.                 Log ("Exception: " + e.ToString());
  24.                 acquiredItemsReceived[i] = new SFS2XItemAttrib(int.Parse(data[i]["id"]));
  25.             }
  26.         }
  27.         return acquiredItemsReceived;
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement