private static void MapPropertiesRecursive(JsonObject jObject, IDirectory directory) { foreach (var file in directory.EnumerateFiles()) { var fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file.Name); if (fileNameWithoutExtension == null || fileNameWithoutExtension == IdPropertyName) continue; if (ReservedPropertyNames.Contains(fileNameWithoutExtension)) throw new DesignDocumentAssemblerException("File name {0} is reserved.", file); if (jObject.ContainsKey(fileNameWithoutExtension)) throw CreateClashingFilesException(directory, fileNameWithoutExtension); jObject[fileNameWithoutExtension] = ReadFile(file); } foreach (var subDirectory in directory.EnumerateDirectories()) { var subDirectoryName = subDirectory.Name; if (ReservedPropertyNames.Contains(subDirectoryName)) throw new DesignDocumentAssemblerException("Directory name {0} is reserved.", subDirectoryName); if (jObject.ContainsKey(subDirectoryName)) throw CreateClashingFilesException(directory, subDirectoryName); var subObject = new JsonObject(); jObject[subDirectoryName] = subObject; MapPropertiesRecursive(subObject, subDirectory); } }
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(); }
/// <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; }
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>${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; }
internal static SmMapServiceInfo FromJson(JsonObject json) { if (json == null) return null; if (!json.ContainsKey("name") || !json.ContainsKey("bounds")) return null; return new SmMapServiceInfo { ViewBounds = JsonHelper.ToRectangle2D((JsonObject)json["viewBounds"]), CoordUnit = (Unit)Enum.Parse(typeof(Unit), (string)json["coordUnit"], true), Bounds = JsonHelper.ToRectangle2D((JsonObject)json["bounds"]), PrjCoordSys = PrjCoordSys.FromJson((JsonObject)json["prjCoordSys"]), Scale = (double)json["scale"], Viewer = JsonHelper.ToRect((JsonObject)json["viewer"]) }; }
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); }
internal static JoinItem FromJson(JsonObject json) { if (json == null) return null; JoinItem item = new JoinItem(); if (json.ContainsKey("foreignTableName")) { item.ForeignTableName = json["foreignTableName"]; } if (json.ContainsKey("joinFilter")) { item.JoinFilter = json["joinFilter"]; } if (json.ContainsKey("joinType") && !string.IsNullOrEmpty(json["joinType"])) { item.JoinType = (JoinType)Enum.Parse(typeof(JoinType), json["joinType"], true); } return item; }
/// <summary>${iServerJava6R_ResultSet_method_fromJson_D}</summary> /// <returns>${iServerJava6R_ResultSet_method_fromJson_return}</returns> /// <param name="json">${iServerJava6R_ResultSet_method_fromJson_param_jsonObject}</param> public static QueryResult FromJson(JsonObject json) { if (json == null) { return null; } QueryResult result = new QueryResult(); if (json.ContainsKey("totalCount") && json.ContainsKey("currentCount") && json.ContainsKey("customResponse") && json.ContainsKey("recordsets")) { result.TotalCount = (int)json["totalCount"]; if ((int)json["totalCount"] == 0) { return null; } result.CurrentCount = (int)json["currentCount"]; result.CustomResponse = (string)json["customResponse"]; JsonArray recordsets = (JsonArray)json["recordsets"]; if (recordsets != null && recordsets.Count > 0) { result.Recordsets = new List<Recordset>(); for (int i = 0; i < recordsets.Count; i++) { result.Recordsets.Add(Recordset.FromJson((JsonObject)recordsets[i])); } } return result; } else if (json.ContainsKey("succeed") && json.ContainsKey("newResourceLocation")) { ResourceInfo info = new ResourceInfo(); info.Succeed = (bool)json["succeed"]; info.NewResourceLocation = (string)json["newResourceLocation"]; info.NewResourceID = (string)json["newResourceID"]; result.ResourceInfo = info; return result; } return null; }
public static SimilarImage JsonToSimilarImage(JsonObject obj) { var keyword = new SimilarImage() { Image = ImagesService.JsonToImage((JsonObject)obj["Image"]), Keyword = obj.ContainsKey("Keyword")? obj["Keyword"].ToString().Replace("\"","") : null, }; return keyword; }
/// <summary>${IS6_Record_method_FromJson_D}</summary> /// <param name="jsonObject">${IS6_Record_method_FromJson_param_jsonObject}</param> /// <returns>${IS6_Record_method_FromJson_return}</returns> public static Record FromJson(JsonObject jsonObject) { if (jsonObject == null) { return null; } Record record = new Record(); if (jsonObject.ContainsKey("bounds") && jsonObject["bounds"] != null) { double mbMinX = (double)jsonObject["bounds"]["leftBottom"]["x"]; double mbMinY = (double)jsonObject["bounds"]["leftBottom"]["y"]; double mbMaxX = (double)jsonObject["bounds"]["rightTop"]["x"]; double mbMaxY = (double)jsonObject["bounds"]["rightTop"]["y"]; record.Bounds = new Rectangle2D(mbMinX, mbMinY, mbMaxX, mbMaxY); } else { record.Bounds = Rectangle2D.Empty; } if (jsonObject.ContainsKey("center") && jsonObject["center"] != null) { record.Center = JsonHelper.ToPoint2D((JsonObject)jsonObject["center"]); } else { record.Center = Point2D.Empty; } if (jsonObject.ContainsKey("shape") && jsonObject["shape"] != null) { record.Shape = ServerGeometry.FromJson((JsonObject)jsonObject["shape"]); } if (jsonObject.ContainsKey("fieldValues") && jsonObject["fieldValues"] != null) { record.FieldValues = JsonHelper.ToStringList((JsonArray)jsonObject["fieldValues"]); } return record; }
internal static ChartAttributeSpec FromJson(JsonObject json) { if (json == null || !json.ContainsKey("code")) { return null; } ChartAttributeSpec attrib = new ChartAttributeSpec(); attrib.Code = (int)json["code"]; attrib.Required = (int)json["required"]; return attrib; }
/// <summary> /// Creates a symbol compatible with Application Framework from JSON object /// </summary> /// <param name="jsonObject">JSON object defining a symbol</param> /// <returns>Symbol</returns> public static Symbol SymbolFromJson(JsonObject jsonObject) { Symbol symb = null; if (jsonObject != null) { string symbType = jsonObject["type"]; if (!string.IsNullOrEmpty(symbType)) { switch (symbType) { case "esriPMS":// REST defined PictureMarkerSymbol --> output: ImageFillSymbol #region ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol imgsymb = new ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol(); double size = 64; // standard size of images used for Viewer symbols if (jsonObject.ContainsKey("width") || jsonObject.ContainsKey("height")) { // Get the greater of the width or height, converting from points to pixels in the process var pointsToPixelsFactor = 4d / 3d; var width = jsonObject.ContainsKey("width") ? jsonObject["width"] * pointsToPixelsFactor : 0; var height = jsonObject.ContainsKey("height") ? jsonObject["height"] * pointsToPixelsFactor : 0; size = width > height ? width : height; } imgsymb.Size = size; if (jsonObject.ContainsKey("xoffset")) imgsymb.OriginX = (size /2 + jsonObject["xoffset"]) / size; if (jsonObject.ContainsKey("yoffset")) imgsymb.OriginY = (size / 2 + jsonObject["yoffset"]) / size; if (jsonObject.ContainsKey("imageData")) imgsymb.ImageData = jsonObject["imageData"]; else if (jsonObject.ContainsKey("url")) imgsymb.Source = jsonObject["url"]; var fill = imgsymb.Fill as ImageBrush; if (fill != null) fill.Stretch = Stretch.Uniform; symb = imgsymb; break; #endregion default: // all other REST defined cases symb = Symbol.FromJson(jsonObject.ToString()); break; } } } return symb; }
/// <summary> /// Creates a symbol compatible with Application Framework from JSON object /// </summary> /// <param name="jsonObject">JSON object defining a symbol</param> /// <returns>Symbol</returns> public static Symbol SymbolFromJson(JsonObject jsonObject) { Symbol symb = null; if (jsonObject != null) { string symbType = jsonObject["type"]; if (!string.IsNullOrEmpty(symbType)) { switch (symbType) { case "esriPMS":// REST defined PictureMarkerSymbol --> output: ImageFillSymbol #region ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol imgsymb = new ESRI.ArcGIS.Mapping.Core.Symbols.ImageFillSymbol(); double size = 64; // standard size of images used for Viewer symbols if (jsonObject.ContainsKey("width")) size = jsonObject["width"]; imgsymb.Size = size; if (jsonObject.ContainsKey("xoffset")) imgsymb.OriginX = (size /2 + jsonObject["xoffset"]) / size; if (jsonObject.ContainsKey("yoffset")) imgsymb.OriginY = (size / 2 + jsonObject["yoffset"]) / size; if (jsonObject.ContainsKey("imageData")) imgsymb.ImageData = jsonObject["imageData"]; else if (jsonObject.ContainsKey("url")) imgsymb.Source = jsonObject["url"]; symb = imgsymb; break; #endregion default: // all other REST defined cases symb = Symbol.FromJson(jsonObject.ToString()); break; } } } return symb; }
/// <summary>${IS6_ThemeRange_method_FromJson_D}</summary> /// <returns>${IS6_ThemeRange_method_FromJson_return}</returns> /// <param name="jsonObject">${IS6_ThemeRange_method_FromJson_param_jsonObject}</param> public static ThemeRange FromJson(JsonObject jsonObject) { if (jsonObject == null) { return null; } ThemeRange result = new ThemeRange { Caption = (string)jsonObject["caption"], Filter = (string)jsonObject["filter"], MaxScale = (double)jsonObject["maxScale"], MinScale = (double)jsonObject["minScale"], ForeignDataParam = ForeignDataParam.FromJson((JsonObject)jsonObject["foreignDataParam"]) }; 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((double)jsonObject["breakValues"][i]); } } if (jsonObject.ContainsKey("displays") && jsonObject["displays"] != null && jsonObject["displays"].Count > 0) { result.Displays = new List<ServerStyle>(); for (int i = 0; i < jsonObject["displays"].Count; i++) { result.Displays.Add(ServerStyle.FromJson((JsonObject)jsonObject["displays"][i])); } } result.Expression = (string)jsonObject["expression"]; return result; }
private static int? GetIntProperty(JsonObject jsonObject, string propertyName) { if (!jsonObject.ContainsKey(propertyName)) return null; var value = jsonObject[propertyName] as JsonPrimitive; if (value != null) { var intValue = value.Value as int?; if (intValue != null) return value.Value as int?; } throw new ParseException("Response property {0} should be integer value", propertyName); }
public static SmMapServiceInfo FromJson(JsonObject jsonObject) { if (jsonObject == null) { return null; } SmMapServiceInfo msi = new SmMapServiceInfo(); msi.MapBounds = JsonHelper.ToRectangle2D((JsonObject)jsonObject["mapBounds"]); msi.ReferViewBounds = JsonHelper.ToRectangle2D((JsonObject)jsonObject["referViewBounds"]); msi.ReferViewer = JsonHelper.ToRect((JsonObject)jsonObject["referViewer"]); msi.ReferScale = (double)jsonObject["referScale"]; if (jsonObject.ContainsKey("coordsSys")) { msi.CRS = JsonHelper.ToCRS((JsonObject)jsonObject["coordsSys"]); } return msi; }
/// <summary>${iServerJava6R_EditFeaturesResult_method_FromJson_D}</summary> /// <returns>${iServerJava6R_EditFeaturesResult_method_FromJson_return}</returns> /// <param name="json">${iServerJava6R_EditFeaturesResult_method_FromJson_param_jsonObject}</param> public static EditFeaturesResult FromJson(JsonObject json) { if (json == null) return null; EditFeaturesResult result = new EditFeaturesResult(); result.Succeed = (bool)json["succeed"]; //TODO: if (json.ContainsKey("newResourceLocation")) { result.NewResourceLocation = (string)json["newResourceLocation"]; } //if (json.ContainsKey("error")) //{ // result.Error = HttpError.FromJson((JsonObject)json["error"]); //} return result; }
static JsonObject CreateJsonObject(Random rndGen, int depth) { const string keyChars = "abcdefghijklmnopqrstuvwxyz0123456789"; int size = rndGen.Next(CreatorSettings.MaxArrayLength); if (CreatorSettings.NullValueProbability == 0 && size == 0) { size++; } JsonObject result = new JsonObject(); for (int i = 0; i < size; i++) { string key; do { key = PrimitiveCreator.CreateInstanceOfString(rndGen, 10, keyChars); } while (result.ContainsKey(key)); result.Add(key, CreateJsonValue(rndGen, depth + 1)); } return result; }
/// <summary>${iServer2_ThemeRange_method_FromJson_D}</summary> /// <returns>${iServer2_ThemeRange_method_FromJson_return}</returns> /// <param name="jsonObject">${iServer2_ThemeRange_method_FromJson_param_jsonObject}</param> public static ThemeRange FromJson(JsonObject jsonObject) { if (jsonObject == null) { return null; } ThemeRange result = new ThemeRange(); result.RangeExpression = (string)jsonObject["rangeExpression"]; if (jsonObject.ContainsKey("items") && jsonObject["items"] != null) { result.Items = new List<ThemeRangeItem>(); for (int i = 0; i < jsonObject["items"].Count; i++) { result.Items.Add(ThemeRangeItem.FromJson((JsonObject)jsonObject["items"][i])); } } result.MakeDefaultParam = ThemeRangeParam.FromJson((JsonObject)jsonObject["makeDefaultParam"]); return result; }
/// <summary>${iServer2_ThemeUnique_method_FromJson_D}</summary> /// <returns>${iServer2_ThemeUnique_method_FromJson_return}</returns> /// <param name="jsonObject">${iServer2_ThemeUnique_method_FromJson_param_jsonObject}</param> public static ThemeUnique FromJson(JsonObject jsonObject) { if (jsonObject == null) { return null; } ThemeUnique result = new ThemeUnique(); result.DefaultStyle = ServerStyle.FromJson((JsonObject)jsonObject["defaultStyle"]); if (jsonObject.ContainsKey("items") && jsonObject["items"] != null) { result.Items = new List<ThemeUniqueItem>(); for (int i = 0; i < jsonObject["items"].Count; i++) { result.Items.Add(ThemeUniqueItem.FromJson((JsonObject)jsonObject["items"][i])); } } result.UniqueExpression = (string)jsonObject["uniqueExpression"]; result.MakeDefaultParam = ThemeUniqueParam.FromJson((JsonObject)jsonObject["makeDefaultParam"]); return result; }
static Element LoadEntry (JsonObject json, bool isPassword) { var caption = GetString (json, "caption"); var value = GetString (json, "value"); var placeholder = GetString (json, "placeholder"); var element = new EntryElement (caption, placeholder, value, isPassword); if (json.ContainsKey ("keyboard")) element.KeyboardType = ToKeyboardType (GetString (json, "keyboard")); if (json.ContainsKey ("return-key")) element.ReturnKeyType = ToReturnKeyType (GetString (json, "return-key")); if (json.ContainsKey ("capitalization")) element.AutocapitalizationType = ToAutocapitalization (GetString (json, "capitalization")); if (json.ContainsKey ("autocorrect")) element.AutocorrectionType = ToAutocorrect (json ["autocorrect"]); return element; }
static JsonArray GetArray (JsonObject obj, string key) { if (obj.ContainsKey (key)) if (obj [key].JsonType == JsonType.Array) return (JsonArray) obj [key]; return null; }
/// <summary>${utility_JsonHelper_method_ToRectangle2D_D}</summary> public static Rectangle2D ToRectangle2D(JsonObject jsonObject) { if (jsonObject == null) { return Rectangle2D.Empty; } if (!jsonObject.ContainsKey("leftBottom") || !jsonObject.ContainsKey("rightTop")) { return Rectangle2D.Empty; } double mbMinX = (double)jsonObject["leftBottom"]["x"]; double mbMinY = (double)jsonObject["leftBottom"]["y"]; double mbMaxX = (double)jsonObject["rightTop"]["x"]; double mbMaxY = (double)jsonObject["rightTop"]["y"]; return new Rectangle2D(mbMinX, mbMinY, mbMaxX, mbMaxY); }
/// <summary>${utility_JsonHelper_method_ToRect_D}</summary> public static Rect ToRect(JsonObject jsonObject) { if (jsonObject == null) { return Rect.Empty; } if (!jsonObject.ContainsKey("leftTop") || !jsonObject.ContainsKey("rightBottom")) { return Rect.Empty; } double viewerMinX = (double)jsonObject["leftTop"]["x"]; double viewerMinY = (double)jsonObject["leftTop"]["y"]; double viewerMaxX = (double)jsonObject["rightBottom"]["x"]; double viewerMaxY = (double)jsonObject["rightBottom"]["y"]; return new Rect(new Point(viewerMinX, viewerMinY), new Point(viewerMaxX, viewerMaxY)); }
/// <summary>${utility_JsonHelper_method_ToPoint2D_D}</summary> public static Point2D ToPoint2D(JsonObject jsonObject) { if (jsonObject == null) { return Point2D.Empty; } if (!jsonObject.ContainsKey("x") || !jsonObject.ContainsKey("y")) { return Point2D.Empty; } return new Point2D() { X = (double)jsonObject["x"], Y = (double)jsonObject["y"] }; }
/// <summary>${utility_JsonHelper_method_ToCRS_D}</summary> public static CoordinateReferenceSystem ToCRS(JsonObject jsonObject) { if (jsonObject == null) { return null; } if (!jsonObject.ContainsKey("pJCoordSysType") || !jsonObject.ContainsKey("coordUnits")) { return null; } int wkid = (int)jsonObject["pJCoordSysType"]; int unitID = (int)jsonObject["coordUnits"]; Unit unit = (Unit)unitID; return new CoordinateReferenceSystem(wkid, unit); }
bool TryPopulate(JsonObject json) { try { Id = json ["id"]; CreatedAt = ParseCreation (json); Text = ParseText (json); Source = Util.StripHtml (HttpUtility.HtmlDecode (json ["source"] ?? "")); Favorited = json ["favorited"]; InReplyToStatus = GetLong (json, "in_reply_to_status_id"); InReplyToUser = GetLong (json, "in_reply_to_user_id"); InReplyToUserName = (string) json ["in_reply_to_screen_name"]; if (json.ContainsKey ("retweeted_status")){ var sub = json ["retweeted_status"]; var subuser = sub ["user"]; // These are swapped out later. Retweeter = subuser ["screen_name"]; RetweeterPicUrl = subuser ["profile_image_url"]; RetweeterId = subuser ["id"]; if (Text.StartsWith ("RT ")) Text = Text.Substring (3); } else { RetweeterPicUrl = null; Retweeter = null; RetweeterId = 0; } return true; } catch (Exception e) { Console.WriteLine (e); return false; } }
/// <summary>${IS6_ThemeUnique_method_FromJson_D}</summary> /// <returns>${IS6_ThemeUnique_method_FromJson_return}</returns> /// <param name="jsonObject">${IS6_ThemeUnique_method_FromJson_param_jsonObject}</param> public static ThemeUnique FromJson(JsonObject jsonObject) { if (jsonObject == null) { return null; } ThemeUnique result = new ThemeUnique { Expression = (string)jsonObject["expression"], DefaultStyle = ServerStyle.FromJson((JsonObject)jsonObject["defaultStyle"]), OnTop = (bool)jsonObject["onTop"], Caption = (string)jsonObject["caption"], Filter = (string)jsonObject["filter"], MaxScale = (double)jsonObject["maxScale"], MinScale = (double)jsonObject["minScale"], ForeignDataParam = ForeignDataParam.FromJson((JsonObject)jsonObject["foreignDataParam"]) }; if (jsonObject.ContainsKey("itemCaptions") && jsonObject["itemCaptions"] != null && jsonObject["itemCaptions"].Count > 0) { result.ItemCaptions = new List<string>(); for (int i = 0; i < jsonObject["itemCaptions"].Count; i++) { result.ItemCaptions.Add((string)jsonObject["itemCaptions"][i]); } } if (jsonObject.ContainsKey("values") && jsonObject["values"] != null && jsonObject["values"].Count > 0) { result.Values = new List<string>(); for (int i = 0; i < jsonObject["values"].Count; i++) { result.Values.Add((string)jsonObject["values"][i]); } } if (jsonObject.ContainsKey("displays") && jsonObject["displays"] != null && jsonObject["displays"].Count > 0) { result.Displays = new List<ServerStyle>(); for (int i = 0; i < jsonObject["displays"].Count; i++) { result.Displays.Add(ServerStyle.FromJson((JsonObject)jsonObject["displays"][i])); } } return result; }
private static bool CompareJsonObjectTypes(JsonObject objA, JsonObject objB) { bool retValue = true; try { if (objA.Keys.Count != objB.Keys.Count) { Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objA.Keys.Count does not match objB.Keys.Count!"); Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objA.Keys.Count = {0}, objB.Keys.Count = {1}", objA.Keys.Count, objB.Keys.Count); return false; } if (objA.Keys.IsReadOnly != objB.Keys.IsReadOnly) { Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objA.Keys.IsReadOnly does not match objB.Keys.IsReadOnly!"); Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objA.Keys.IsReadOnly = {0}, objB.Keys.IsReadOnly = {1}", objA.Keys.IsReadOnly, objB.Keys.IsReadOnly); return false; } else { foreach (string keyA in objA.Keys) { if (!objB.ContainsKey(keyA)) { Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objB does not contain Key " + keyA + "!"); return false; } if (!Compare(objA[keyA], objB[keyA])) { Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objA[" + keyA + "] = " + objA[keyA]); Log.Info("JsonValueVerifier (JsonObjectTypes) Error: objB[" + keyA + "] = " + objB[keyA]); return false; } } } } catch (Exception e) { Log.Info("JsonValueVerifier (JsonObjectTypes) Error: An Exception was thrown: " + e); return false; } return retValue; }
/// <summary>${iServerJava6R_ServerLayer_method_FromJson_D}</summary> /// <returns>${iServerJava6R_ServerLayer_method_FromJson_return}</returns> /// <param name="json">${iServerJava6R_ServerLayer_method_FromJson_param_jsonObject}</param> public static ServerLayer FromJson(JsonObject json) { var serverLayer = new ServerLayer(); if (json["bounds"] != null) { serverLayer.Bounds = JsonHelper.ToRectangle2D((JsonObject)json["bounds"]); } else { //null } serverLayer.Caption = (string)json["caption"]; serverLayer.Description = (string)json["description"]; serverLayer.Name = (string)json["name"]; serverLayer.IsQueryable = (bool)json["queryable"]; serverLayer.IsVisible = (bool)json["visible"]; serverLayer.IsCompleteLineSymbolDisplayed = (bool)json["completeLineSymbolDisplayed"]; serverLayer.MaxScale = (double)json["maxScale"]; serverLayer.MinScale = (double)json["minScale"]; serverLayer.MinVisibleGeometrySize = (double)json["minVisibleGeometrySize"]; serverLayer.OpaqueRate = (int)json["opaqueRate"]; serverLayer.IsSymbolScalable = (bool)json["symbolScalable"]; serverLayer.SymbolScale = (double)json["symbolScale"]; serverLayer.DatasetInfo = DatasetInfo.FromJson((JsonObject)json["datasetInfo"]); serverLayer.DisplayFilter = (string)json["displayFilter"]; if (json["joinItems"] != null) { List<JoinItem> joinItems = new List<JoinItem>(); foreach (JsonObject item in (JsonArray)json["joinItems"]) { joinItems.Add(JoinItem.FromJson(item)); } serverLayer.JoinItems = joinItems; } serverLayer.RepresentationField = (string)json["representationField"]; if ((string)json["ugcLayerType"] == SuperMapLayerType.GRID.ToString()) { UGCGridLayer ugcGridLayer = new UGCGridLayer(); List<Color> colors = new List<Color>(); foreach (JsonObject colorItem in (JsonArray)json["colors"]) { colors.Add(ServerColor.FromJson(colorItem).ToColor()); } ugcGridLayer.Colors = colors; if (json["dashStyle"] != null) { ugcGridLayer.DashStyle = ServerStyle.FromJson((JsonObject)json["dashStyle"]); } if (json["gridType"] != null) { ugcGridLayer.GridType = (GridType)Enum.Parse(typeof(GridType), json["gridType"], true); } else { } ugcGridLayer.HorizontalSpacing = (double)json["horizontalSpacing"]; ugcGridLayer.SizeFixed = (bool)json["sizeFixed"]; if (json["solidStyle"] != null) { ugcGridLayer.SolidStyle = ServerStyle.FromJson((JsonObject)json["solidStyle"]); } if (json["specialColor"] != null) { ugcGridLayer.SpecialColor = ServerColor.FromJson((JsonObject)json["specialColor"]).ToColor(); } ugcGridLayer.SpecialValue = (double)json["specialValue"]; ugcGridLayer.VerticalSpacing = (double)json["verticalSpacing"]; serverLayer.UGCLayer = ugcGridLayer; } else if ((string)json["ugcLayerType"] == SuperMapLayerType.IMAGE.ToString()) { UGCImageLayer ugcImageLayer = new UGCImageLayer(); ugcImageLayer.Brightness = (int)json["brightness"]; if (json["colorSpaceType"] != null) { ugcImageLayer.ColorSpaceType = (ColorSpaceType)Enum.Parse(typeof(ColorSpaceType), (string)json["colorSpaceType"], true); } else { } ugcImageLayer.Contrast = (int)json["contrast"]; List<int> bandIndexes = new List<int>(); if (json["displayBandIndexes"] != null && ((JsonArray)json["displayBandIndexes"]).Count > 0) { foreach (int item in (JsonArray)json["displayBandIndexes"]) { bandIndexes.Add(item); } ugcImageLayer.DisplayBandIndexes = bandIndexes; } ugcImageLayer.Transparent = (bool)json["transparent"]; ugcImageLayer.TransparentColor = ServerColor.FromJson((JsonObject)json["transparentColor"]).ToColor(); serverLayer.UGCLayer = ugcImageLayer; } else if ((string)json["ugcLayerType"] == SuperMapLayerType.THEME.ToString()) { UGCThemeLayer ugcThemeLayer = new UGCThemeLayer(); if (json["theme"] != null) { if ((string)json["theme"]["type"] == "UNIQUE") { ugcThemeLayer.Theme = ThemeUnique.FromJson((JsonObject)json["theme"]); } else if ((string)json["theme"]["type"] == "RANGE") { ugcThemeLayer.Theme = ThemeRange.FromJson((JsonObject)json["theme"]); } else if ((string)json["theme"]["type"] == "LABEL") { ugcThemeLayer.Theme = ThemeLabel.FromJson((JsonObject)json["theme"]); } else if ((string)json["theme"]["type"] == "GRAPH") { ugcThemeLayer.Theme = ThemeGraph.FromJson((JsonObject)json["theme"]); } else if ((string)json["theme"]["type"] == "DOTDENSITY") { ugcThemeLayer.Theme = ThemeDotDensity.FromJson((JsonObject)json["theme"]); } else if ((string)json["theme"]["type"] == "GRADUATEDSYMBOL") { ugcThemeLayer.Theme = ThemeGraduatedSymbol.FromJson((JsonObject)json["theme"]); } else { //以后有需求再添加,现在就写到这里,共六个专题图。 } } if (json["theme"]["type"] != null) { ugcThemeLayer.ThemeType = (ThemeType)Enum.Parse(typeof(ThemeType), (string)json["theme"]["type"], true); } serverLayer.UGCLayer = ugcThemeLayer; //ugcThemeLayer.Theme } else if ((string)json["ugcLayerType"] == SuperMapLayerType.VECTOR.ToString() && json.ContainsKey("style")) { serverLayer.UGCLayer = UGCVectorLayer.FromJson((JsonObject)json["style"]); } else { serverLayer.UGCLayer = new UGCLayer(); } if (json["ugcLayerType"] != null) { serverLayer.UGCLayerType = (SuperMapLayerType)Enum.Parse(typeof(SuperMapLayerType), (string)json["ugcLayerType"], true); } else { //不做处理 } //这里不判断WMS和WFS图层。 //else if (json["ugcLayerType"] == SuperMapLayerType.WMS.ToString()) //{ //} //根据图层类型增加相应属性。 return serverLayer; }