Ejemplo n.º 1
0
 public static void SerializeSystemBoolean(bool[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }
		public JSONArray GetDataSource()
		{
			var array = new JSONArray ();

		
			array.Put(new JSONObject().Put("Country","Brazil").Put("Population",204436000).Put("ShortName","BRA"));
			array.Put(new JSONObject().Put("Country","United States").Put("Population",321174000).Put("ShortName","USA"));
			array.Put(new JSONObject().Put("Country","Russia").Put("Population",146267288).Put("ShortName","RUS"));
			array.Put(new JSONObject().Put("Country","India").Put("Population",1272470000).Put("ShortName","IND"));
			array.Put(new JSONObject().Put("Country","China").Put("Population",1370320000).Put("ShortName","CHI"));
			array.Put(new JSONObject().Put("Country","Indonesia").Put("Population",255461700).Put("ShortName","INO"));

			return array;
		}
Ejemplo n.º 3
0
        public static string ToJsonString(this byte[] objs)
        {
            //TODO: byte array is a special one, convert to base64?
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put((int)obj);
            }

            return array.ToString();
        }
Ejemplo n.º 4
0
        public static string ToJsonString(this short[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put((long)obj);
            }

            return array.ToString();
        }
Ejemplo n.º 5
0
 // Encrypt the receipts and save them to file.
 static void ToCache(IList<Receipt> receipts, string gamerUuid)
 {
     OuyaFacade.Log("Caching receipts");
     var json = new JSONObject();
     var array = new JSONArray();
     foreach (var receipt in receipts)
     {
         var r = new JSONObject();
         r.Put("identifier", receipt.Identifier);
         // PriceInCents is now deprecated. Use LocalPrice and CurrencyCode instead.
         // Retain field for compatibility.
         r.Put("priceInCents", 0);
         r.Put("purchaseDate", receipt.PurchaseDate.ToGMTString());
         r.Put("generatedDate", receipt.GeneratedDate.ToGMTString());
         r.Put("gamerUuid", receipt.Gamer);
         r.Put("uuid", receipt.Uuid);
         r.Put("localPrice", receipt.LocalPrice);
         r.Put("currencyCode", receipt.Currency);
         array.Put(r);
     }
     json.Accumulate("receipts", array);
     var text = json.ToString();
     var encryptedReceipts = CryptoHelper.Encrypt(text, gamerUuid);
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         using (var writer = new StreamWriter(store.OpenFile(receiptsFileName, FileMode.OpenOrCreate)))
         {
             writer.Write(encryptedReceipts);
         }
     }
 }
Ejemplo n.º 6
0
 // Encrypt the receipts and save them to file.
 void ToCache(IList<Receipt> receipts)
 {
     OuyaFacade.Log("Caching receipts");
     var json = new JSONObject();
     var array = new JSONArray();
     foreach (var receipt in receipts)
     {
         var r = new JSONObject();
         r.Put("identifier", receipt.Identifier);
         r.Put("priceInCents", receipt.PriceInCents);
         r.Put("purchaseDate", receipt.PurchaseDate.ToGMTString());
         r.Put("generatedDate", receipt.GeneratedDate.ToGMTString());
         r.Put("gamerUuid", receipt.Gamer);
         r.Put("uuid", receipt.Uuid);
         array.Put(r);
     }
     json.Accumulate("receipts", array);
     var text = json.ToString();
     var encryptedReceipts = CryptoHelper.Encrypt(text, _gamerUuid);
     using (var store = IsolatedStorageFile.GetUserStoreForApplication())
     {
         using (var writer = new StreamWriter(store.OpenFile(receiptsFileName, FileMode.OpenOrCreate)))
         {
             writer.Write(encryptedReceipts);
         }
     }
 }
Ejemplo n.º 7
0
 public static void SerializeSystemString(string[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }
Ejemplo n.º 8
0
 public static void SerializeSystemInt16(short[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }
Ejemplo n.º 9
0
 public static void SerializeSystemDouble(double[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }
Ejemplo n.º 10
0
        public static string ToJsonString(this ulong[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put(obj.ToString());
            }

            return array.ToString();
        }
Ejemplo n.º 11
0
 public static void SerializeSystemDateTime(DateTime[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(JsonConvert.ToString(obj));
     }
 }
Ejemplo n.º 12
0
 public static void SerializeSystemDecimal(decimal[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }
Ejemplo n.º 13
0
 [Inline]  //enum support
 protected static void AddToJsonArray(JSONArray jsonArray, long obj)
 {
     jsonArray.Put(obj);
 }
Ejemplo n.º 14
0
 protected static void AddToJsonArray(JSONArray jsonArray, JSONObject obj)
 {
     jsonArray.Put(obj);
 }
Ejemplo n.º 15
0
 public static void SerializeSystemUInt64(ulong[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }
Ejemplo n.º 16
0
        public static string ToJsonString(this float[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put((double)obj);
            }

            return array.ToString();
        }
Ejemplo n.º 17
0
        private Weather CallbackResponse(string responseObj)
        {
            Weather weather = null;


            Org.Json.JSONObject weatherMain = new Org.Json.JSONObject(responseObj);

            Org.Json.JSONArray weatherArray = new Org.Json.JSONArray();
            weatherArray.Put(weatherMain);


            for (int i = 0; i < weatherArray.Length(); i++)
            {
                try
                {
                    Org.Json.JSONObject weatherObject = weatherArray.GetJSONObject(i);

                    JSONObject objectLocation = weatherObject.GetJSONObject("location");
                    JSONObject objectCurrent  = weatherObject.GetJSONObject("current");

                    //JSONObject objectrequest = objectCurrent.GetJSONObject("request");
                    //"request":{ "type":"City","query":"Tel Aviv-Yafo, Israel","language":"en","unit":"m"}

                    weather = new Weather();

                    weather.setTemperature(objectCurrent.GetString("temperature"));
                    weather.setDescription(objectCurrent.GetString("weather_descriptions"));
                    weather.setWind_kph(objectCurrent.GetString("wind_speed"));
                    string icon = objectCurrent.GetString("weather_icons");
                    icon = icon.Replace("[\"" + "https:\\/\\/assets", @"https://assets");
                    icon = icon.Replace("[", "");
                    icon = icon.Replace("]", "");
                    icon = icon.Replace("\"", "");
                    icon = icon.Replace(@"\/", "//");
                    icon = icon.Replace(@"\\", "//");
                    //Android.Net.Uri uri = Android.Net.Uri.Parse(icon);
                    //Android.Net.Uri uri = Android.Net.Uri.Parse(icon);
                    //icon = uri.Path;
                    //icon = uri.AbsolutePath;
                    weather.setPoster(icon);
                    weather.setIs_day(objectCurrent.GetString("is_day").ToString());
                    weather.setCloud(objectCurrent.GetString("cloudcover"));

                    weather.setLast_update(objectLocation.GetString("localtime"));
                    weather.setCountry(objectLocation.GetString("country"));
                    icon = objectLocation.GetString("name").Trim();
                    icon = icon.Replace(@"[", "");
                    icon = icon.Replace("[", "");
                    icon = icon.Replace(@"]", "");
                    icon = icon.Replace("]", "");
                    icon = icon.Replace("\"", "");
                    icon = icon.Replace("\"", "");
                    icon = icon.Replace("[\"", "");
                    //icon = icon.Replace('\'', (char)32);
                    weather.setCity(icon.Trim());         // "type":"City","query":"Tel Aviv-Yafo, Israel"
                    weather.setRegion(objectLocation.GetString("region"));
                    weather.setLocal_time(objectLocation.GetString("localtime"));
                    weather.setTz_id(objectLocation.GetString("timezone_id"));

                    //"localtime_epoch":1583177400,"utc_offset":"2.0"
                    //wind_degree":311,"wind_dir":"NW","pressure":1021,"precip":0,"humidity":60,"cloudcover":7,"feelslike":17

                    try
                    {
                        //weather.setImageView(Utils.GetImageViewFromhUrl(weather.getPoster()));
                        //weather.setImageView(new ImageView(Application.Context));
                        //Android.Net.Uri uri = Android.Net.Uri.Parse(weather.getPoster());
                        //weather.getImageView().SetImageURI(uri);
                    }
                    catch
                    {
                    }

                    if (WeatherList.Count < 4)
                    {
                        WeatherList.Add(weather);
                    }
                    else
                    {
                        WeatherList[currentListIndex] = weather;
                    }
                }
                catch (JSONException ex)
                {
                    MH_Utils.Utils.WriteToLog(ex.Message);
                    //Log.d("Error: ", ex.getMessage());
                    //ex.printStackTrace();
                }
            }


            return(weather);
        }
Ejemplo n.º 18
0
        public static string ToJsonString(this TimeSpan[] objs)
        {
            var array = new JSONArray();
            foreach (var obj in objs)
            {
                array.Put(JsonConvert.ToString(obj));
            }

            return array.ToString();
        }
Ejemplo n.º 19
0
 public static void SerializeSystemGuid(Guid[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj.ToString());
     }
 }
Ejemplo n.º 20
0
		JSONArray GetDataSource()
		{
			JSONArray array = new JSONArray ();

			array.Put(getJsonObject("Alabama", "Vegetables", 9 ));
			array.Put(getJsonObject( "Alaska", "Vegetables", 3 ));
			array.Put(getJsonObject( "Arizona", "Rice", 11 ));
			array.Put(getJsonObject( "Arkansas", "Vegetables", 6 ));
			array.Put(getJsonObject( "California", "Rice", 55 ));
			array.Put(getJsonObject( "Colorado", "Rice", 9 ));
			array.Put(getJsonObject( "Connecticut", "Grains", 7 ));
			array.Put(getJsonObject( "Delaware", "Grains", 3 ));
			array.Put(getJsonObject( "District of Columbia", "Grains", 3 ));
			array.Put(getJsonObject( "Florida", "Rice", 29 ));
			array.Put(getJsonObject( "Georgia", "Rice", 16 ));
			array.Put(getJsonObject( "Hawaii", "Grains", 4 ));
			array.Put(getJsonObject( "Idaho", "Grains", 4 ));
			array.Put(getJsonObject( "Illinois", "Vegetables", 20 ));
			array.Put(getJsonObject( "Indiana", "Grains", 11 ));
			array.Put(getJsonObject( "Iowa", "Vegetables", 6 ));
			array.Put(getJsonObject( "Kansas", "Rice", 6 ));
			array.Put(getJsonObject( "Kentucky", "Grains", 8 ));
			array.Put(getJsonObject( "Louisiana", "Rice", 8 ));
			array.Put(getJsonObject( "Maine", "Grains", 4 ));
			array.Put(getJsonObject( "Maryland", "Grains", 10 ));
			array.Put(getJsonObject( "Massachusetts", "Grains", 11 ));
			array.Put(getJsonObject( "Michigan", "Grains", 16 ));
			array.Put(getJsonObject( "Minnesota", "Wheat", 10 ));
			array.Put(getJsonObject( "Mississippi", "Vegetables", 6 ));
			array.Put(getJsonObject( "Missouri", "Vegetables", 10 ));
			array.Put(getJsonObject( "Montana", "Grains", 3 ));
			array.Put(getJsonObject( "Nebraska", "Rice", 5 ));
			array.Put(getJsonObject( "Nevada", "Wheat", 6 ));
			array.Put(getJsonObject( "New Hampshire", "Grains", 4 ));
			array.Put(getJsonObject( "New Jersey", "Vegetables", 14 ));
			array.Put(getJsonObject( "New Mexico", "Rice", 5 ));
			array.Put(getJsonObject( "New York", "Vegetables", 29 ));
			array.Put(getJsonObject( "North Carolina", "Rice", 15 ));
			array.Put(getJsonObject( "North Dakota", "Grains", 3 ));
			array.Put(getJsonObject( "Ohio", "Vegetables", 18 ));
			array.Put(getJsonObject( "Oklahoma", "Rice", 7 ));
			array.Put(getJsonObject( "Oregon", "Wheat", 7 ));
			array.Put(getJsonObject( "Pennsylvania", "Vegetables", 20 ));
			array.Put(getJsonObject( "Rhode Island", "Grains", 4 ));
			array.Put(getJsonObject( "South Carolina", "Rice", 9 ));
			array.Put(getJsonObject( "South Dakota", "Grains", 3 ));
			array.Put(getJsonObject( "Tennessee", "Vegetables", 11 ));
			array.Put(getJsonObject( "Texas", "Vegetables", 38 ));
			array.Put(getJsonObject( "Utah", "Rice", 6 ));
			array.Put(getJsonObject( "Vermont", "Grains", 3 ));
			array.Put(getJsonObject( "Virginia", "Rice", 13 ));
			array.Put(getJsonObject( "Washington", "Vegetables", 12 ));
			array.Put(getJsonObject( "West Virginia", "Grains", 5 ));
			array.Put(getJsonObject( "Wisconsin", "Grains", 10 ));
			array.Put(getJsonObject( "Wyoming", "Wheat", 3 ));
			return array;
		}
Ejemplo n.º 21
0
 public static void SerializeSystemSingle(float[] objs, JSONArray jsonArray)
 {
     foreach (var obj in objs)
     {
         jsonArray.Put(obj);
     }
 }