internal static HapticEffectMode ToMode(JSONObject jsonObj) { var mode = new HapticEffectMode(); mode.Mode = EnumParser.ToMode(jsonObj["mode"]); mode.DotMode = DotMode.ToDotMode(jsonObj["dotMode"].AsObject); mode.PathMode = PathMode.ToPathMode(jsonObj["pathMode"].AsObject); return(mode); }
internal static HapticEffectMode ToMode(JsonObject jsonObj) { var mode = new HapticEffectMode(); mode.Mode = EnumParser.ToMode(jsonObj.GetNamedString("mode")); mode.DotMode = DotMode.ToDotMode(jsonObj.GetNamedObject("dotMode", new JsonObject()).GetObject()); mode.PathMode = PathMode.ToPathMode(jsonObj.GetNamedObject("pathMode", new JsonObject()).GetObject()); return(mode); }
public static PlayerResponse ToObject(string jsonStr) { var jsonObject = JSON.Parse(jsonStr); var obj = new PlayerResponse(); obj.ConnectedDeviceCount = (int)jsonObject["ConnectedDeviceCount"]; obj.RegisteredKeys = new List <string>(); foreach (var jsonValue in jsonObject["RegisteredKeys"].AsArray) { obj.RegisteredKeys.Add(jsonValue.Value); } obj.ActiveKeys = new List <string>(); foreach (var jsonValue in jsonObject["ActiveKeys"].AsArray) { obj.ActiveKeys.Add(jsonValue.Value); } obj.ConnectedPositions = new List <PositionType>(); foreach (var jsonValue in jsonObject["ConnectedPositions"].AsArray) { obj.ConnectedPositions.Add(EnumParser.ToPositionType(jsonValue.Value)); } obj.Status = new Dictionary <string, int[]>(); var status = jsonObject[("Status")]; foreach (var statusKey in status.Keys) { var arr = status[statusKey]; var item = new int[arr.Count]; var i = 0; foreach (var jsonValue in arr) { item[i] = jsonValue.Value.AsInt; i++; } obj.Status[statusKey] = item; } return(obj); }
internal static PathModeObjectCollection ToObject(JSONObject jsonObject) { var collection = new PathModeObjectCollection(); collection.PlaybackType = EnumParser.ToPlaybackType(jsonObject.GetValueOrDefault("playbackType", "NONE")); collection.MovingPattern = EnumParser.ToMovingPattern(jsonObject["movingPattern"]); List <PathModeObject> list = new List <PathModeObject>(); foreach (var jsonValue in jsonObject.GetValueOrDefault("pointList", new JSONArray())) { list.Add(PathModeObject.ToObject(jsonValue.Value.AsObject)); } collection.PointList = list.ToArray(); return(collection); }
internal static PathModeObjectCollection ToObject(JsonObject jsonObject) { var collection = new PathModeObjectCollection(); collection.PlaybackType = EnumParser.ToPlaybackType(jsonObject.GetNamedString("playbackType", "NONE")); collection.MovingPattern = EnumParser.ToMovingPattern(jsonObject.GetNamedString("movingPattern")); List <PathModeObject> list = new List <PathModeObject>(); foreach (var jsonValue in jsonObject.GetNamedArray("pointList", new JsonArray())) { list.Add(PathModeObject.ToObject(jsonValue.GetObject())); } collection.PointList = list.ToArray(); return(collection); }
internal static PlayerResponse ToObject(string jsonStr) { JsonObject jsonObject = JsonObject.Parse(jsonStr); var obj = new PlayerResponse(); obj.ConnectedDeviceCount = (int)jsonObject.GetNamedNumber("ConnectedDeviceCount"); obj.RegisteredKeys = new List <string>(); foreach (var jsonValue in jsonObject.GetNamedArray("RegisteredKeys", new JsonArray())) { obj.RegisteredKeys.Add(jsonValue.GetString()); } obj.ActiveKeys = new List <string>(); foreach (var jsonValue in jsonObject.GetNamedArray("ActiveKeys", new JsonArray())) { obj.ActiveKeys.Add(jsonValue.GetString()); } obj.ConnectedPositions = new List <PositionType>(); foreach (var jsonValue in jsonObject.GetNamedArray("ConnectedPositions", new JsonArray())) { obj.ConnectedPositions.Add(EnumParser.ToPositionType(jsonValue.GetString())); } obj.Status = new Dictionary <string, int[]>(); var status = jsonObject.GetNamedObject("Status"); foreach (var statusKey in status.Keys) { var arr = status.GetNamedArray(statusKey, new JsonArray()); var item = new int[arr.Count]; var i = 0; foreach (var jsonValue in arr) { item[i] = (int)jsonValue.GetNumber(); i++; } obj.Status[statusKey] = item; } return(obj); }
internal static DotModeObjectCollection ToObject(JSONObject val) { var obj = new DotModeObjectCollection(); obj.StartTime = ParseUtil.GetInt(val, "startTime"); obj.EndTime = ParseUtil.GetInt(val, "endTime"); obj.PlaybackType = EnumParser.ToPlaybackType(val.GetValueOrDefault("playbackType", "NONE")); var list = new List <DotModeObject>(); foreach (var jsonValue in val["pointList"]) { list.Add(DotModeObject.ToObject(jsonValue.Value.AsObject)); } obj.PointList = list.ToArray(); return(obj); }
internal static DotModeObjectCollection ToObject(JsonObject val) { var obj = new DotModeObjectCollection(); obj.StartTime = (int)val.GetNamedNumber("startTime"); obj.EndTime = (int)val.GetNamedNumber("endTime"); obj.PlaybackType = EnumParser.ToPlaybackType(val.GetNamedString("playbackType", "NONE")); var list = new List <DotModeObject>(); foreach (var jsonValue in val.GetNamedArray("pointList", new JsonArray())) { list.Add(DotModeObject.ToObject(jsonValue.GetObject())); } obj.PointList = list.ToArray(); return(obj); }