Esempio n. 1
0
        protected Boolean handleUnregistered(JsonObject t, UnregisteredErrorCallback mCallback, Callback mCallbackPost)
        {
            if (t.ContainsKey("response_error"))
            {
                JsonObject er = (System.Json.JsonObject)t["response_error"];
                Console.WriteLine("Contains resp error" + er["response_code"].Equals("40")
                                  );


                if (Int32.Parse(er["response_code"]) == 40)
                {
                    Console.WriteLine("COntains 40");

                    Console.WriteLine("Unregister");
                    try
                    {
                        UnregisteredError e = JsonConvert.DeserializeObject <UnregisteredError>(
                            t.ToString());
                        mCallback.onUserNotRegistered(e);
                        //   Console.WriteLine("UNREG");
                        return(true);
                    }
                    catch (Exception e)
                    {
                        mCallbackPost.onFailure(e);
                    }
                }
            }
            Console.WriteLine("Not Unregister");

            return(false);
        }
Esempio n. 2
0
        public JsonObject Post(JsonObject contact)
        {
            if (contact == null)
            {
                throw new ArgumentNullException("contact");
            }

            contact.ValidateStringLength("What", 1, MaxFieldLength)
                   .ValidateCustomValidator("StartDate", typeof(CustomValidator), "ValidateMeetingTime")
                   .ValidateStringLength("Where", 1, MaxFieldLength)
                   .ValidateStringLength("Description", MaxFieldLength)
                   .ValidateCustomValidator("ReminderValue", typeof(CustomValidator), "ValidateReminder")
                   .ValidateEnum("ShowMeAs", typeof(ShowMeAs))
                   .ValidateCustomValidator("Guests", typeof(CustomValidator), "ValidateGuestEmails");

            string modifyEventName = "ModifyEvent";
            if (contact.ContainsKey(modifyEventName))
            {
                contact.ValidateTypeOf<bool>(modifyEventName);
            }

            string inviteOthersName = "InviteOthers";
            if (contact.ContainsKey(inviteOthersName))
            {
                contact.ValidateTypeOf<bool>(inviteOthersName);
            }

            string seeGuestListName = "SeeGuestList";
            if (contact.ContainsKey(seeGuestListName))
            {
                contact.ValidateTypeOf<bool>(seeGuestListName);
            }

            return new JsonObject();
        }
Esempio n. 3
0
        public static List<Graphic> ReadGeoJSON( JsonObject jsonObject )
        {
            jsonObject.RequireArgument<JsonObject>( "jsonObject" ).NotNull<JsonObject>();

            if( !jsonObject.Keys.Contains( TYPE_IDENTIFIER ) )
                throw new InvalidOperationException( "The GeoJSON object must contain a VALID type property." );

            string type = ( string ) jsonObject[ TYPE_IDENTIFIER ];
            if( !GEOJSON_TYPES.Contains<string>( type ) )
                throw new InvalidOperationException( "The type property value '" + type + "' is not a valid GeoJSON type." );

            if( type == FEATURE_COLLECTION_TYPE_NAME )
                return ReadFeatures( jsonObject );

            if( type == FEATURE_TYPE_NAME )
                return ReadFeature( jsonObject );

            if( GEOMETRY_TYPES.Contains<string>( type ) )
            {
                List<Geometry> geometries = ReadGeometry( jsonObject );
                List<Graphic> graphics = new List<Graphic>();
                foreach( Geometry item in geometries )
                {
                    graphics.Add( new Graphic()
                    {
                        Geometry = item,
                        Symbol = item.GetDefaultSymbol()
                    } );
                }
                return graphics;
            }

            throw new InvalidOperationException( "The type property value '" + type + "' is not a valid GeoJSON type." );
        }
 public static void Run()
 {
     var config = new HttpConfiguration();
     config.RequestHandlers += (coll, ep, desc) =>
                                  {
                                      if (
                                          desc.Attributes.Any(a => a.GetType() == typeof(JsonExtractAttribute))
                                          )
                                      {
                                          coll.Add(new JsonExtractHandler(desc));    
                                      }
                                  };
     using (var sh = new HttpServiceHost(typeof(TheService), config, "http://localhost:8080"))
     {
         sh.Open();
         Console.WriteLine("host is opened");
         var client = new HttpClient();
         dynamic data = new JsonObject();
         data.x = "a string";
         data.y = "13";
         data.z = "3.14";
         var resp = client.PostAsync("http://localhost:8080/v2", new ObjectContent<JsonValue>(data, "application/json")).Result;
         Console.WriteLine(resp.StatusCode);
     }
 }
        /// <summary>${iServer2_DataTable_method_FromJson_D}</summary>
        /// <param name="jsonObject">${iServer2_DataTable_method_FromJson_param_jsonObject}</param>
        /// <returns>${iServer2_DataTable_method_FromJson_return}</returns>
        public static DataTable FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }
            DataTable dt = new DataTable();

            JsonArray columnsInJson = (JsonArray)jsonObject["columns"];
            if (columnsInJson != null && columnsInJson.Count > 0)
            {
                dt.Columns = new List<DataColumn>();
                for (int i = 0; i < columnsInJson.Count; i++)
                {
                    dt.Columns.Add(DataColumn.FromJson((JsonObject)columnsInJson[i]));
                }
            }
            JsonArray rowsInJson = (JsonArray)jsonObject["rows"];
            if (rowsInJson != null && rowsInJson.Count > 0)
            {
                dt.Rows = new List<DataRow>();
                for (int i = 0; i < rowsInJson.Count; i++)
                {
                    dt.Rows.Add(DataRow.FromJson((JsonObject)rowsInJson[i]));
                }
            }

            return dt;
        }
        /// <summary>${iServer2_ResultSet_method_FromJson_D}</summary>
        /// <returns>${iServer2_ResultSet_method_FromJson_return}</returns>
        /// <param name="jsonObject">${iServer2_ResultSet_method_FromJson_param_jsonObject}</param>
        public static ResultSet FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            ResultSet resultSet = new ResultSet();
            resultSet.TotalCount = (int)jsonObject["totalCount"];
            if (resultSet.TotalCount == 0)
            {
                return null;
            }//如果为0,认为结果为空?
            resultSet.CurrentCount = (int)jsonObject["currentCount"];
            resultSet.CustomResponse = (string)jsonObject["customResponse"];

            JsonArray recordSets = (JsonArray)jsonObject["recordSets"];
            if (recordSets != null && recordSets.Count > 0)
            {
                resultSet.RecordSets = new List<RecordSet>();
                for (int i = 0; i < recordSets.Count; i++)
                {
                    resultSet.RecordSets.Add(RecordSet.FromJson((JsonObject)recordSets[i]));
                }
            }
            return resultSet;
        }
        //方法
        /// <summary>${iServer2_GetMapStatusResult_method_FromJson_D}</summary>
        /// <param name="jsonObject">${iServer2_GetMapStatusResult_method_FromJson_param_jsonObject}</param>
        /// <returns>${iServer2_GetMapStatusResult_method_FromJson_return}</returns>
        public static GetMapStatusResult FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            GetMapStatusResult result = new GetMapStatusResult();

            #region
            result.MapName = (string)jsonObject["mapName"];
            result.MapBounds = ToRectangle2D((JsonObject)jsonObject["mapBounds"]);
            result.ReferViewBounds = ToRectangle2D((JsonObject)jsonObject["referViewBounds"]);
            result.ReferViewer = ToRect((JsonObject)jsonObject["referViewer"]);
            result.ReferScale = (double)jsonObject["referScale"];
            result.CRS = ToCRS((JsonObject)jsonObject["coordsSys"]);
            #endregion
            if (jsonObject["layers"] != null && jsonObject["layers"].Count > 0)
            {
                result.ServerLayers = new List<ServerLayer>();
                for (int i = 0; i < jsonObject["layers"].Count; i++)
                {
                    result.ServerLayers.Add(ServerLayer.FromJson((JsonObject)jsonObject["layers"][i]));
                }
            }

            return result;
        }
Esempio n. 8
0
 public CustomRootElement(string title, JsonObject data)
     : base(title)
 {
     this.data = data;
     apiNode = DrupalApiParser.FromJsonObject(data);
     //apiNode = ApiNode.
 }
Esempio n. 9
0
        internal static JsonObject Parse(IEnumerable<Tuple<string, string>> nameValuePairs, int maxDepth)
        {
            JsonObject result = new JsonObject();
            foreach (var nameValuePair in nameValuePairs)
            {
                if (nameValuePair.Item1 == null)
                {
                    if (string.IsNullOrEmpty(nameValuePair.Item2))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                            new ArgumentException(DiagnosticUtility.GetString(SR.QueryStringNameShouldNotNull), "nameValuePairs"));
                    }

                    string[] path = new string[] { nameValuePair.Item2 };
                    Insert(result, path, null);
                }
                else
                {
                    string[] path = GetPath(nameValuePair.Item1, maxDepth);
                    Insert(result, path, nameValuePair.Item2);
                }
            }

            FixContiguousArrays(result);
            return result;
        }
        /// <summary>${iServerJava6R_DatasetInfo_method_FromJson_D}</summary>
        /// <returns>${iServerJava6R_DatasetInfo_method_FromJson_return}</returns>
        /// <param name="jsonObject">${iServerJava6R_DatasetInfo_method_FromJson_param_jsonObject}</param>
        public static DatasetInfo FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }
            DatasetInfo result = new DatasetInfo();
            result.Name = (string)jsonObject["name"];

            if (jsonObject["type"] != null)
            {
                result.Type = (DatasetType)Enum.Parse(typeof(DatasetType), (string)jsonObject["type"], true);
            }
            else
            {
            }
            result.DatasourceName = (string)jsonObject["dataSourceName"];
            if (jsonObject["bounds"] != null)
            {
                result.Bounds = DatasetInfo.ToRectangle2D((JsonObject)jsonObject["bounds"]);
            }
            else
            {  }
            return result;
        }
Esempio n. 11
0
        public void AddRangeParamsTest()
        {
            string key1 = AnyInstance.AnyString;
            string key2 = AnyInstance.AnyString2;
            JsonValue value1 = AnyInstance.AnyJsonValue1;
            JsonValue value2 = AnyInstance.AnyJsonValue2;

            List<KeyValuePair<string, JsonValue>> items = new List<KeyValuePair<string, JsonValue>>()
            {
                new KeyValuePair<string, JsonValue>(key1, value1),
                new KeyValuePair<string, JsonValue>(key2, value2),
            };

            JsonObject target;

            target = new JsonObject();
            target.AddRange(items[0], items[1]);
            Assert.AreEqual(2, target.Count);
            ValidateJsonObjectItems(target, key1, value1, key2, value2);

            target = new JsonObject();
            target.AddRange(items.ToArray());
            Assert.AreEqual(2, target.Count);
            ValidateJsonObjectItems(target, key1, value1, key2, value2);

            ExceptionTestHelper.ExpectException<ArgumentNullException>(delegate { new JsonObject().AddRange((KeyValuePair<string, JsonValue>[])null); });
            ExceptionTestHelper.ExpectException<ArgumentNullException>(delegate { new JsonObject().AddRange((IEnumerable<KeyValuePair<string, JsonValue>>)null); });

            items[1] = new KeyValuePair<string, JsonValue>(key2, AnyInstance.DefaultJsonValue);
            ExceptionTestHelper.ExpectException<ArgumentException>(delegate { new JsonObject().AddRange(items.ToArray()); });
            ExceptionTestHelper.ExpectException<ArgumentException>(delegate { new JsonObject().AddRange(items[0], items[1]); });
        }
Esempio n. 12
0
 public static void Add(this MultipartFormDataContent source, JsonObject json)
 {
     foreach(var kv in json)
     {
         source.Add(kv);
     };
 }
        /// <summary>${iServerJava6R_FindLocationAnalystResult_method_fromJson_D}</summary>
        /// <returns>${iServerJava6R_FindLocationAnalystResult_method_fromJson_Return}</returns>
        /// <param name="json">${iServerJava6R_FindLocationAnalystResult_method_fromJson_param_jsonObject}</param>
        public static FindLocationAnalystResult FromJson(JsonObject json)
        {
            if (json == null)
                return null;

            FindLocationAnalystResult result = new FindLocationAnalystResult();
            //result.MapImage = NAResultMapImage.FromJson((JsonObject)json["mapImage"]);

            if (json["demandResults"] != null && json["demandResults"].Count > 0)
            {
                result.DemandResults = new List<DemandResult>();
                for (int i = 0; i < json["demandResults"].Count; i++)
                {
                    result.DemandResults.Add(DemandResult.FromJson((JsonObject)json["demandResults"][i]));
                }
            }
            if (json["supplyResults"] != null && json["supplyResults"].Count > 0)
            {
                result.SupplyResults = new List<SupplyResult>();
                for (int i = 0; i < json["supplyResults"].Count; i++)
                {
                    result.SupplyResults.Add(SupplyResult.FromJson((JsonObject)json["supplyResults"][i]));
                }
            }

            return result;
        }
Esempio n. 14
0
 public void ReciveData(JsonObject reciveData)
 {
     this.reciveData = reciveData;
     if (reciveData["command"] == "areaData") {
         UpdateMap(reciveData["areaDatas"]);
     }
 }
        public void PostToWall()
        {
            try
            {
                var actionLinks = new JsonArray();

                var learnMore = new JsonObject();
                learnMore.Add("text", "Learn more about Big Profile");
                learnMore.Add("href", "http://myapp.no/BigProfile");

                var appStore = new JsonObject();
                appStore.Add("text", "Visit App Store");
                appStore.Add("href", "http://myapp.no/BigProfileAppStore");

                //actionLinks.Add(learnMore);
                actionLinks.Add(appStore);

                var attachment = new JsonObject();
                attachment.Add("name", "Big Profile");
                attachment.Add("description", "Make your profile stand out with a big profile picture stretched across the new Facebook design. Available in App Store!");
                attachment.Add("href", "http://myapp.no/BigProfile");

                var parameters = new NSMutableDictionary();
                parameters.Add(new NSString("user_message_prompt"), new NSString("Tell your friends"));
                parameters.Add(new NSString("attachment"), new NSString(attachment.ToString()));
                parameters.Add(new NSString("action_links"), new NSString(actionLinks.ToString()));

                _facebook.Dialog("stream.publish", parameters, facebookDialogDelegate);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Exception when showing dialog: {0}", ex);
            }
        }
        /// <summary>${IS6_ForeignDataParam_method_FromJson_D}</summary>
        /// <param name="jsonObject">${IS6_ForeignDataParam_method_FromJson_D}</param>
        /// <returns>${IS6_ForeignDataParam_method_FromJson_return}</returns>
        public static ForeignDataParam FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }
            ForeignDataParam result = new ForeignDataParam();

            result.ForeignJoinExpression = (string)jsonObject["foreignJoinExpression"];
            result.UseForeignValue = (bool)jsonObject["useForeignValue"];

            if (jsonObject.ContainsKey("foreignKeys") && jsonObject["foreignKeys"] != null && jsonObject["foreignKeys"].Count > 0)
            {
                result.ForeignKeys = new List<string>();
                for (int i = 0; i < jsonObject["foreignKeys"].Count; i++)
                {
                    result.ForeignKeys.Add((string)jsonObject["foreignKeys"][i]);
                }
            }

            if (jsonObject.ContainsKey("foreignValues") && jsonObject["foreignValues"] != null && jsonObject["foreignValues"].Count > 0)
            {
                result.ForeignValues = new List<string>();
                for (int i = 0; i < jsonObject["foreignValues"].Count; i++)
                {
                    result.ForeignValues.Add((string)jsonObject["foreignValues"][i]);
                }
            }

            return result;
        }
        /// <summary>${iServerJava6R_GetFeaturesResult_method_fromJson_D}</summary>
        /// <returns>${iServerJava6R_GetFeaturesResult_method_fromJson_return}</returns>
        /// <param name="json">${iServerJava6R_GetFeaturesResult_method_fromJson_param_jsonObject}</param>
        public static GetFeaturesResult FromJson(JsonObject json)
        {
            if (json == null)
                return null;

            GetFeaturesResult result = new GetFeaturesResult();
            result.FeatureCount = (int)json["featureCount"];
            if (result.FeatureCount < 1)
            {
                return null;
            }

            JsonArray features = (JsonArray)json["features"];
            if (features != null && features.Count > 0)
            {
                result.Features = new FeatureCollection();

                for (int i = 0; i < features.Count; i++)
                {
                    ServerFeature f = ServerFeature.FromJson((JsonObject)features[i]);
                    result.Features.Add(f.ToFeature());
                }
            }

            return result;
        }
Esempio n. 18
0
        public void sendRequestHttpPost(string url, JsonObject mJsonObject, Dictionary <String, String> headers, Callback mCallbackPost)
        {
            var client = new RestClient(url);

            // client.Authenticator = new HttpBasicAuthenticator(username, password);
            Console.Write("URL? " + url);
            var request = new RestRequest();

            Console.WriteLine("sending " + mJsonObject.ToString());
            request.AddJsonBody(mJsonObject.ToString());
            client.PostAsync(request, (IRestResponse arg1, RestRequestAsyncHandle arg2) =>
            {
                var o = JsonObject.Parse(arg1.Content);
                if (mCallbackPost != null)
                {
                    JsonObject obj = (System.Json.JsonObject)o;
                    Console.WriteLine("received2 " + obj.ToString());
                    if (handleUnregistered(obj, getHandler(), mCallbackPost))
                    {
                        return;
                    }
                    else
                    {
                        Console.WriteLine("Handle normally");
                        mCallbackPost.onResponse(obj);
                    }
                }
            });
        }
        /// <summary>${iServer2_EditResult_method_FromJson_D}</summary>
        /// <param name="jsonObject">${iServer2_EditResult_method_FromJson_param_jsonObject}</param>
        /// <returns>${iServer2_EditResult_method_FromJson_return}</returns>
        public static EditResult FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            EditResult result = new EditResult();

            result.Succeed = (bool)jsonObject["succeed"];

            JsonArray idsInJson = (JsonArray)jsonObject["ids"];
            if (idsInJson.Count > 0 && idsInJson != null)
            {
                result.IDs = new List<int>();
                for (int i = 0; i < idsInJson.Count; i++)
                {
                    result.IDs.Add(idsInJson[i]);
                }
            }

            if (jsonObject["editBounds"] != null)
            {
                double mbMinX = (double)jsonObject["editBounds"]["leftBottom"]["x"];
                double mbMinY = (double)jsonObject["editBounds"]["leftBottom"]["y"];
                double mbMaxX = (double)jsonObject["editBounds"]["rightTop"]["x"];
                double mbMaxY = (double)jsonObject["editBounds"]["rightTop"]["y"];
                result.EditBounds = new Rectangle2D(mbMinX, mbMinY, mbMaxX, mbMaxY);
            }

            result.Message = (string)jsonObject["message"];
            return result;
        }
        internal static ThemeGridRange FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            ThemeGridRange result = new ThemeGridRange();

            if (jsonObject.ContainsKey("breakValues") && jsonObject["breakValues"] != null && jsonObject["breakValues"].Count > 0)
            {
                result.BreakValues = new List<double>();
                for (int i = 0; i < jsonObject["breakValues"].Count; i++)
                {
                    result.BreakValues.Add(jsonObject["breakValues"][i]);
                }

            }
            if (jsonObject.ContainsKey("displays") && jsonObject["displays"] != null && jsonObject["displays"].Count > 0)
            {
                result.Displays = new List<ServerColor>();
                for (int i = 0; i < jsonObject["displays"].Count; i++)
                {
                    result.Displays.Add(ServerColor.FromJson(jsonObject["displays"][i]));
                }

            }
            result.Caption = (string)jsonObject["caption"];
            return result;
        }
		/// <summary>
		/// 設定を保存します
		/// </summary>
		public async Task Save()
		{
			await Task.Run(() =>
			{
				// Serialize
				var json = new JsonObject();
				JsonPrimitive element;

				JsonPrimitive.TryCreate(Account.BaseUrl, out element);
				json.Add("BaseUrl", element);

				JsonPrimitive.TryCreate(Account.UserKey, out element);
				json.Add("UserKey", element);

				JsonPrimitive.TryCreate(PostTextFormat, out element);
				json.Add("PostTextFormat", element);

				JsonPrimitive.TryCreate((int)TargetPlayer, out element);
				json.Add("TargetPlayer", element);

				JsonPrimitive.TryCreate(IsAutoPost, out element);
				json.Add("IsAutoPost", element);

				JsonPrimitive.TryCreate(AutoPostInterval, out element);
				json.Add("AutoPostInterval", element);

				// Save
				using (var sw = new System.IO.StreamWriter("setting.json"))
				{
					json.Save(sw);
				}
			});
		}
Esempio n. 22
0
        public static BaseMessage ParseMessage(JsonObject messageObject)
        {
            BaseMessage message = null;
            string type = messageObject["poll_type"].ToString().Replace("\"", "");

            switch (type)
            {
                case "message":
                    message = ParseFriendMessage(messageObject);
                    break;
                case "sess_message":
                    break;
                case "system_message":
                    break;
                case "group_message":
                    message = ParseGroupMessage(messageObject);
                    break;
                case "sys_g_msg":
                    message = ParseGroupSystemMessage(messageObject);
                    break;
                default:
                    break;
            }
            return message;
        }
Esempio n. 23
0
        protected JsonObject Call(string subpath, string method = "GET",  string contentType = "application/text",
            string data = "")
        {
            string uri;

            uri = String.Format("https://{0}{1}", _options["api_base"],
                                    GetPath(subpath));

            if(_sessionId != null && _sessionId != "")
            {
                uri = String.Format("{0}{1}", uri, String.Format("&hs={0}", _sessionId));
            }

            Debug.WriteLine(uri);
            var returnVal = UserWebClient.UploadString(uri, method: method, contentType: contentType, data: data);

            if (returnVal != null)
            {
                if (returnVal.Length > 0)
                {
                    JsonObject o = new JsonObject(JsonValue.Parse(returnVal));
                    if (SuccessfulCall(o))
                    {
                        return o;
                    }
                    else
                    {
                        var response = JsonConvert.DeserializeObject<Helpers.APIResponse>(o.ToString());
                        throw new Exception(String.Format("Unsuccessful call to web api. {0}", response.result.code), new Exception(String.Format("{0}", response.result.description)));
                    }
                }
            }

            return new JsonObject();
        }
Esempio n. 24
0
        static public Tuple <string, int> excavate(IRestClient client)
        {
            Console.WriteLine("EXCAVATE!");
            var request = new RestRequest(String.Format("v1/excavate"), Method.POST);

            request.Timeout          = 500;
            request.ReadWriteTimeout = 400;

            Policy retryPolicy = Policy.Handle <Exception>().Retry(3);

            try {
                System.Json.JsonObject result = retryPolicy.Execute(() => {
                    IRestResponse response = client.Execute(request);
                    return(JsonValue.Parse(response.Content));
                }) as System.Json.JsonObject;
                if (result != null && result.Keys.Contains("bucketId") && result.Keys.Contains("gold"))
                {
                    return(new Tuple <string, int> (result["bucketId"], result["gold"]["units"]));
                }
            }catch (Exception) {
                return(null);
            }

            return(null);
        }
 /// <summary>${IS6_ServerGeometry_method_FromJson_D}</summary>
 /// <param name="jsonObject">${IS6_ServerGeometry_method_FromJson_param_jsonObject}</param>
 /// <returns>${IS6_ServerGeometry_method_FromJson_return}</returns>
 public static ServerGeometry FromJson(JsonObject jsonObject)
 {
     if (jsonObject == null)
     {
         return null;
     }
     ServerGeometry geometry = new ServerGeometry();
     geometry.Feature = (ServerFeatureType)(int)jsonObject["feature"];
     geometry.ID = (int)jsonObject["id"];
     JsonArray parts = (JsonArray)jsonObject["parts"];
     if (parts != null && parts.Count > 0)
     {
         geometry.Parts = new List<int>();
         for (int i = 0; i < parts.Count; i++)
         {
             geometry.Parts.Add((int)parts[i]);
         }
     }
     JsonArray point2Ds = (JsonArray)jsonObject["points"];
     if (point2Ds != null && point2Ds.Count > 0)
     {
         geometry.Point2Ds = new Point2DCollection();
         for (int i = 0; i < point2Ds.Count; i++)
         {
             geometry.Point2Ds.Add(JsonHelper.ToPoint2D((JsonObject)point2Ds[i]));
         }
     }
     return geometry;
 }
Esempio n. 26
0
 public void Build(JsonObject input)
 {
     using (_profiler.Step("DeploymentService.Build"))
     {
         _deploymentManager.Deploy((string)input["id"]);
     }
 }
Esempio n. 27
0
 public void Delete(JsonObject input)
 {
     using (_profiler.Step("DeploymentService.Delete"))
     {
         _deploymentManager.Delete((string)input["id"]);
     }
 }
Esempio n. 28
0
 public void PostEntry()
 {
     var json = new JsonObject();
     json["command"] = "entry";
     var send = "data=" + json.ToString();
     network.SendPostRequest(send);
 }
        internal static LabelMixedTextStyle FromJson(JsonObject json)
        {
            if (json == null) return null;
            LabelMixedTextStyle textStyle = new LabelMixedTextStyle();
            textStyle.DefaultStyle = ServerTextStyle.FromJson((JsonObject)json["defaultStyle"]);
            textStyle.Separator = (string)json["separator"];
            textStyle.SeparatorEnabled = (bool)json["separatorEnabled"];

            if ((JsonArray)json["splitIndexes"] != null && ((JsonArray)json["splitIndexes"]).Count > 0)
            {
                List<int> list = new List<int>();
                foreach (int item in (JsonArray)json["splitIndexes"])
                {
                    list.Add(item);
                }
                textStyle.SplitIndexes = list;
            }

            if (json["styles"] != null)
            {
                List<ServerTextStyle> textStyleList = new List<ServerTextStyle>();
                foreach (JsonObject item in (JsonArray)json["styles"])
                {
                    textStyleList.Add(ServerTextStyle.FromJson(item));
                }
                textStyle.Styles = textStyleList;
            }

            return textStyle;
        }
        static JsonObject JsonObj(PushNotification notification)
        {
            var jsonObj = new JsonObject();

            jsonObj["aps"] = JsonObject(notification.Payload);
            if (notification.DeviceTokens != null)
            {
                jsonObj["device_tokens"] = notification.DeviceTokens.ToJsonArray();
            }
            if (notification.Aliases != null)
            {
                jsonObj["aliases"] = notification.Aliases.ToJsonArray();
            }
            if (notification.Tags != null)
            {
                jsonObj["tags"] = notification.Tags.ToJsonArray();
            }
            if (notification.ExcludeTokens != null)
            {
                jsonObj["exclude_tokens"] = notification.ExcludeTokens.ToJsonArray();
            }

            if (notification.CustomData != null)
            {
                foreach (var pair in notification.CustomData)
                {
                    ValidateKey(pair.Key);
                    jsonObj[pair.Key] = pair.Value;
                }
            }

            return jsonObj;
        }
        public static JsonObject JsonObject(PushPayload pushPayload)
        {
            var aps = new JsonObject();

            if (pushPayload.Alert != null)
            {
                aps["alert"] = pushPayload.Alert;
            }
            if (pushPayload.Badge != null)
            {
                if (pushPayload.Badge is string)
                {
                    aps["badge"] = pushPayload.Badge as string;
                }
                else if (pushPayload.Badge is int)
                {
                    aps["badge"] = (int)pushPayload.Badge;
                }
                else
                {
                    throw new Exception("Badge is not in valid format");
                }
            }
            if (pushPayload.Sound != null)
            {
                aps["sound"] = pushPayload.Sound;
            }
            return aps;
        }
        /// <summary>${iServerJava6R_GeometryOverlayAnalystResult_method_fromJson_D}</summary>
        /// <returns>${iServerJava6R_GeometryOverlayAnalystResult_method_fromJson_return}</returns>
        /// <param name="jsonResult">${iServerJava6R_GeometryOverlayAnalystResult_method_fromJson_param_jsonObject }</param>
        public static GeometryOverlayAnalystResult FromJson(JsonObject jsonResult)
        {
            GeometryOverlayAnalystResult result = new GeometryOverlayAnalystResult();
            result.ResultGeometry = (ServerGeometry.FromJson(jsonResult)).ToGeometry();

            return result;
        }
        /// <summary>${iServer2_DataReturnOption_method_FromJson_D}</summary>
        /// <param name="jsonObject">${iServer2_DataReturnOption_method_FromJson_param_jsonObject}</param>
        /// <returns>${iServer2_DataReturnOption_method_FromJson_return}</returns>
        public static DataReturnOption FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            DataReturnOption drp = new DataReturnOption();

            if (jsonObject.ContainsKey("dataset"))
            {
                drp.Dataset = (string)jsonObject["dataset"];
            }

            if (jsonObject.ContainsKey("maxRecordCount"))
            {
                drp.MaxRecordCount = (int)jsonObject["maxRecordCount"];
            }

            if (jsonObject.ContainsKey("overwriteIfExists"))
            {
                drp.OverwriteIfExists = (bool)jsonObject["overwriteIfExists"];
            }

            if (jsonObject.ContainsKey("returnMode"))
            {
                drp.ReturnMode = (DataReturnMode)((int)jsonObject["returnMode"]);
            }
            return drp;
        }
 private static string CreateMetodRequestString(string proceDb, string proceName, string[] paramKeys, string[] paramVals)
 {
     System.Json.JsonObject _jsonObj = new System.Json.JsonObject();
     _jsonObj.Add("ProceDb", proceDb);
     _jsonObj.Add("ProceName", proceName);
     _jsonObj.Add("ParamKeys", ConvertObjectAry2JsonValAry(paramKeys));
     _jsonObj.Add("ParamVals", ConvertObjectAry2JsonValAry(paramVals));
     return(new JsonArray(_jsonObj).ToString());
 }
Esempio n. 35
0
        static public string login(RestClient client, string userName)
        {
            string uid = string.Empty;

            var request = new RestRequest(String.Format("v1/register?userName={0}", userName), Method.POST);

            request.ReadWriteTimeout = 400;
            request.Timeout          = 1000;
            try{
                IRestResponse response = client.Execute(request);
                Console.WriteLine(response.StatusCode.ToString());
                System.Json.JsonObject result = JsonValue.Parse(response.Content) as System.Json.JsonObject;

                if (result != null && result.Keys.Contains("user"))
                {
                    Console.WriteLine("Login OK");
                    return(result["user"]);
                }
            }catch (Exception) {
                return(string.Empty);
            }
            return(String.Empty);
        }
Esempio n. 36
0
 public void sendRequestHttpPost(string url, JsonObject mJsonObject, Callback mCallbackPost)
 {
     sendRequestHttpPost(url, mJsonObject, new Dictionary <String, String>(), mCallbackPost);
 }