public virtual string GetRowData(SharpObject source) { var reverseAliases = new Dictionary <string, string>(); foreach (var alias in ColumnAliases) { reverseAliases[alias.Value] = alias.Key; } RowData.Clear(); Column = 0; foreach (var column in ColumnNames) { string colname; if (!reverseAliases.TryGetValue(column.Value, out colname)) { colname = column.Value; } if (!source.ContainsKey(colname)) { AppendEmptyColumn(1); } else { // TODO: apply formatting, padding, alignment etc. here var value = (source[colname] ?? "").ToString(); AppendJustifyLeft(value); } } return(RowData.ToString()); }
public virtual void OnMemberChanged(SharpObject source, string fieldName, object value) { if (Collection != null) { Collection.OnMemberChanged(this, source, fieldName, value); } }
public SharpObject Apply(SharpObject record, SharpObject context) { var obj = ApplyMap(Map, record, context); if (MergeSourceFields) { obj.MergeWith(record); } if (CopyRecordFields) { var target = RootNode == RecordFieldNode ? obj : obj.GetMemberObject(RecordFieldNode, o => o); if (target == null) { target = new SharpObject(); obj[RecordFieldNode] = target; } foreach (var item in record) { if (!target.ContainsKey(item.Key)) { target[item.Key] = item.Value; } } } return(obj); }
public void ToObjectTest() { var sharpObject = SharpObject.Copy(new { test1 = 1, test2 = "test", test3 = true }); var obj = sharpObject.ToObject <TestObject>(); Assert.AreEqual(obj.Test1, 1); }
public virtual void Write(SharpObject source) { if (Buffer != null) { var line = RowFormat.GetRowData(source); WriteLine(line); } }
//public static Dictionary<string, object> AsDictionary(this object obj) //{ // return SharpObject.Copy(obj).Clone().ToDictionary(); //} public static T ToObject <T>(this SharpObject obj) { var instance = typeof(T).GetConstructor(new Type[] { }).Invoke(new object[] { }); foreach (var field in instance.GetType().GetProperties()) { var fieldName = field.Name.CamelCase(); field.SetValue(instance, obj[fieldName]); } return((T)instance); }
public void ConvertTest() { try { var json = "[\n {\n \"slug\": \"chiefs-at-buccaneers-2020-post-4\",\n \"gameDetail\": {\n \"seasonType\": \"POST\",\n \"visitorTimeoutsUsed\": 3,\n \"playReview\": false,\n \"stadium\": \"Raymond James Stadium\",\n \"broadcastInfo\": {\n \"homeNetworkChannels\": [\n \"CBS\",\n \"ESPN DEPORTES\"\n ],\n \"territory\": \"NATIONAL\",\n \"awayNetworkChannels\": [\n \"CBS\",\n \"ESPN DEPORTES\"\n ]\n },\n \"ticketUrl\": \"https://www.ticketmaster.com/super-bowl-lv-tampa-florida-02-07-2021/event/0D005A24C12D8483\",\n \"visitorTimeoutsRemaining\": 0,\n \"visitorPointsOvertimeTotal\": 0,\n \"homePointsOvertimeTotal\": 0,\n \"venue\": {\n \"name\": \"Raymond James Stadium\",\n \"id\": \"00083697-451e-88a5-6695-aa32961fba3a\"\n },\n \"attendance\": \"24,835\",\n \"weather\": {\n \"location\": \"null\",\n \"currentRealFeelFahrenheit\": \"null\",\n \"shortDescription\": \"Clear Temp: 63° F, Humidity: 78%, Wind: NW 9 mph\",\n \"currentFahrenheit\": \"null\",\n \"longDescription\": \"null\"\n },\n \"season\": 2020,\n \"date\": \"2021-02-07\",\n \"yardsToGo\": 0,\n \"homePointsQ1\": 7,\n \"goalToGo\": true,\n \"category\": \"OTHER\",\n \"homePointsTotal\": 31,\n \"homeTimeoutsUsed\": 0,\n \"visitorPointsOvertime\": \"null\",\n \"gameClock\": \"00:30\",\n \"id\": \"10012021-0207-0069-5207-a78dd8bf8075\",\n \"redzone\": false,\n \"status\": \"SCHEDULED\",\n \"visitorPointsTotal\": 9,\n \"homePointsQ2\": 14,\n \"homePointsQ4\": 0,\n \"yardLine\": \"null\",\n \"down\": 0,\n \"weekType\": \"SB\",\n \"homePointsQ3\": 10,\n \"phase\": \"FINAL\",\n \"distance\": 12,\n \"visitorPointsQ2\": 3,\n \"period\": \"null\",\n \"homePointsOvertime\": \"null\",\n \"visitorPointsQ4\": 0,\n \"possessionTeam\": {\n \"abbreviation\": \"TB\"\n },\n \"visitorPointsQ1\": 3,\n \"startTime\": \"18:30:00\",\n \"time\": \"2021-02-07T17:30:00-06:00\",\n \"week\": 4,\n \"homeTimeoutsRemaining\": 3,\n \"externalIds\": [\n {\n \"id\": \"2021020700\",\n \"source\": \"elias\"\n },\n {\n \"source\": \"gsis\",\n \"id\": \"58501\"\n },\n {\n \"id\": \"10160000-0585-01aa-36fc-5a38a4f1dbb9\",\n \"source\": \"gamedetail\"\n },\n {\n \"id\": \"10012021-0207-0069-5207-a78dd8bf8075\",\n \"source\": \"shield\"\n },\n {\n \"id\": \"chiefs-at-buccaneers-2020-post-4\",\n \"source\": \"slug\"\n }\n ],\n \"visitorPointsQ3\": 3\n },\n \"id\": \"10012021-0207-0069-5207-a78dd8bf8075\",\n \"awayTeamId\": \"kc\",\n \"gameUrls\": {\n \"nflUrls\": {\n \"gamecast\": \"https://www.nfl.com/games/chiefs-at-buccaneers-2020-post-4\"\n },\n \"espnUrls\": {\n \"teamStats\": \"https://www.espn.com/nfl/matchup?gameId=401220403\",\n \"game\": \"https://www.espn.com/nfl/game_/gameId/401220403\",\n \"recap\": \"https://www.espn.com/nfl/recap?gameId=401220403\",\n \"boxscore\": \"https://www.espn.com/nfl/boxscore_/gameId/401220403\",\n \"playbyplay\": \"https://www.espn.com/nfl/playbyplay_/gameId/401220403\"\n }\n },\n \"gameTime\": \"2021-02-07T17:30:00-06:00\",\n \"seasonType\": \"POST\",\n \"gameId\": \"chiefs-at-buccaneers-2020-post-4\",\n \"lastUpdated\": \"2021-06-03T16:04:03.793952-05:00\",\n \"seasonWeekId\": \"2020-POST-4\",\n \"homeTeam\": {\n \"nflSlug\": \"tampa-bay-buccaneers\",\n \"location\": \"Tampa Bay\",\n \"divisionFullName\": \"NFC South\",\n \"colors\": {\n \"primary\": \"#A71930\",\n \"secondary\": \"#322F2B\",\n \"tertiary\": \"#000000\"\n },\n \"conferenceAbbr\": \"NFC\",\n \"nickName\": \"Buccaneers\",\n \"conferenceFullName\": \"National Football Conference\",\n \"espnTeam\": {\n \"uid\": \"s:20~l:28~t:27\",\n \"id\": \"27\",\n \"location\": \"Tampa Bay\",\n \"logos\": [\n {\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500/tb.png\",\n \"rel\": [\n \"full\",\n \"default\"\n ],\n \"alt\": \"\",\n \"height\": 500,\n \"width\": 500\n },\n {\n \"width\": 500,\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500-dark/tb.png\",\n \"alt\": \"\",\n \"height\": 500,\n \"rel\": [\n \"full\",\n \"dark\"\n ]\n },\n {\n \"width\": 500,\n \"alt\": \"\",\n \"height\": 500,\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/tb.png\",\n \"rel\": [\n \"full\",\n \"scoreboard\"\n ]\n },\n {\n \"width\": 500,\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500-dark/scoreboard/tb.png\",\n \"rel\": [\n \"full\",\n \"scoreboard\",\n \"dark\"\n ],\n \"height\": 500,\n \"alt\": \"\"\n }\n ],\n \"slug\": \"tampa-bay-buccaneers\",\n \"record\": {},\n \"color\": \"A80D08\",\n \"links\": [\n {\n \"isExternal\": false,\n \"shortText\": \"Clubhouse\",\n \"language\": \"en-US\",\n \"text\": \"Clubhouse\",\n \"href\": \"https://www.espn.com/nfl/team/_/name/tb/tampa-bay-buccaneers\",\n \"isPremium\": false,\n \"rel\": [\n \"clubhouse\",\n \"desktop\",\n \"team\"\n ]\n },\n {\n \"isExternal\": false,\n \"shortText\": \"Roster\",\n \"text\": \"Roster\",\n \"rel\": [\n \"roster\",\n \"desktop\",\n \"team\"\n ],\n \"isPremium\": false,\n \"href\": \"http://www.espn.com/nfl/team/roster/_/name/tb/tampa-bay-buccaneers\",\n \"language\": \"en-US\"\n },\n {\n \"text\": \"Statistics\",\n \"rel\": [\n \"stats\",\n \"desktop\",\n \"team\"\n ],\n \"href\": \"http://www.espn.com/nfl/team/stats/_/name/tb/tampa-bay-buccaneers\",\n \"isPremium\": false,\n \"language\": \"en-US\",\n \"isExternal\": false,\n \"shortText\": \"Statistics\"\n },\n {\n \"isExternal\": false,\n \"language\": \"en-US\",\n \"shortText\": \"Schedule\",\n \"rel\": [\n \"schedule\",\n \"desktop\",\n \"team\"\n ],\n \"isPremium\": false,\n \"href\": \"https://www.espn.com/nfl/team/schedule/_/name/tb\",\n \"text\": \"Schedule\"\n },\n {\n \"isExternal\": false,\n \"rel\": [\n \"photos\",\n \"desktop\",\n \"team\"\n ],\n \"href\": \"https://www.espn.com/nfl/team/photos/_/name/tb\",\n \"isPremium\": false,\n \"text\": \"photos\",\n \"language\": \"en-US\",\n \"shortText\": \"photos\"\n },\n {\n \"text\": \"Scores\",\n \"isPremium\": false,\n \"rel\": [\n \"scores\",\n \"sportscenter\",\n \"app\",\n \"team\"\n ],\n \"language\": \"en-US\",\n \"shortText\": \"Scores\",\n \"href\": \"sportscenter://x-callback-url/showClubhouse?uid=s:20~l:28~t:27§ion=scores\",\n \"isExternal\": false\n },\n {\n \"language\": \"en-US\",\n \"isPremium\": true,\n \"text\": \"Draft Picks\",\n \"rel\": [\n \"draftpicks\",\n \"desktop\",\n \"team\"\n ],\n \"isExternal\": false,\n \"href\": \"http://www.espn.com/nfl/draft/teams/_/name/tb/tampa-bay-buccaneers\",\n \"shortText\": \"Draft Picks\"\n },\n {\n \"rel\": [\n \"transactions\",\n \"desktop\",\n \"team\"\n ],\n \"language\": \"en-US\",\n \"shortText\": \"Transactions\",\n \"isExternal\": false,\n \"isPremium\": false,\n \"text\": \"Transactions\",\n \"href\": \"https://www.espn.com/nfl/team/transactions/_/name/tb\"\n },\n {\n \"text\": \"Injuries\",\n \"isPremium\": false,\n \"language\": \"en-US\",\n \"href\": \"https://www.espn.com/nfl/team/injuries/_/name/tb\",\n \"shortText\": \"Injuries\",\n \"rel\": [\n \"injuries\",\n \"desktop\",\n \"team\"\n ],\n \"isExternal\": false\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/depth/_/name/tb\",\n \"rel\": [\n \"depthchart\",\n \"desktop\",\n \"team\"\n ],\n \"isExternal\": false,\n \"text\": \"Depth Chart\",\n \"language\": \"en-US\",\n \"isPremium\": false,\n \"shortText\": \"Depth Chart\"\n },\n {\n \"text\": \"Tickets\",\n \"isExternal\": true,\n \"isPremium\": false,\n \"language\": \"en\",\n \"href\": \"https://www.vividseats.com/nfl-football/tampa-bay-buccaneers-tickets.html?wsUser=717\",\n \"rel\": [\n \"tickets\",\n \"desktop\",\n \"team\"\n ]\n }\n ],\n \"abbreviation\": \"TB\",\n \"displayName\": \"Tampa Bay Buccaneers\",\n \"isAllStar\": false,\n \"nickname\": \"Tampa Bay\",\n \"shortDisplayName\": \"Buccaneers\",\n \"name\": \"Buccaneers\",\n \"alternateColor\": \"34302b\",\n \"isActive\": true\n },\n \"teamId\": \"tb\",\n \"fullName\": \"Tampa Bay Buccaneers\",\n \"league\": \"National Football League\",\n \"abbreviation\": \"tb\",\n \"url\": {\n \"espn\": {\n \"stats\": \"https://www.espn.com/nfl/team/stats/_/name/tb\",\n \"transactions\": \"https://www.espn.com/nfl/team/transactions/_/name/tb\",\n \"depthChart\": \"https://www.espn.com/nfl/team/depth/_/name/tb\",\n \"teamStats\": \"https://www.espn.com/nfl/team/stats/_/type/team/name/tb\",\n \"team\": \"https://www.espn.com/nfl/team/_/name/tb\",\n \"roster\": \"https://www.espn.com/nfl/team/roster/_/name/tb\",\n \"teamStatsHistory\": \"https://www.espn.com/nfl/team/stats/_/type/team/name/tb/season/{seasonYear}/seasontype/2\",\n \"schedule\": \"https://www.espn.com/nfl/team/schedule/_/name/tb\",\n \"injuries\": \"https://www.espn.com/nfl/team/injuries/_/name/tb\"\n },\n \"nfl\": {\n \"team\": \"https://www.nfl.com/teams/tampa-bay-buccaneers\",\n \"roster\": \"https://www.nfl.com/teams/tampa-bay-buccaneers/roster\",\n \"stats\": \"https://www.nfl.com/teams/tampa-bay-buccaneers/stats\"\n }\n },\n \"id\": \"10404900-d59e-b449-ef75-961e09ca027e\",\n \"teamType\": \"TEAM\",\n \"venues\": [\n {\n \"name\": \"Raymond James Stadium\",\n \"id\": \"00083697-451e-88a5-6695-aa32961fba3a\"\n }\n ],\n \"logos\": {\n \"png\": \"https://static.www.nfl.com/league/api/clubs/logos/TB.png\",\n \"svg\": \"https://static.www.nfl.com/league/api/clubs/logos/TB.svg\"\n },\n \"espnTeamId\": \"tb\",\n \"currentLogo\": \"https://static.www.nfl.com/{formatInstructions}/league/api/clubs/logos/TB\"\n },\n \"networkChannels\": [\n \"CBS\",\n \"ESPN DEPORTES\"\n ],\n \"espnGame\": {\n \"status\": {\n \"type\": {\n \"description\": \"Final\",\n \"completed\": true,\n \"state\": \"post\",\n \"shortDetail\": \"Final\",\n \"id\": \"3\",\n \"name\": \"STATUS_FINAL\",\n \"detail\": \"Final\"\n },\n \"displayClock\": \"0:00\",\n \"period\": 4\n },\n \"links\": [\n {\n \"text\": \"Gamecast\",\n \"href\": \"https://www.espn.com/nfl/game/_/gameId/401220403\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/boxscore/_/gameId/401220403\",\n \"text\": \"Box Score\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/video?gameId=401220403\",\n \"text\": \"Highlights\"\n },\n {\n \"text\": \"Play-by-Play\",\n \"href\": \"http://www.espn.com/nfl/playbyplay/_/gameId/401220403\"\n }\n ],\n \"awayTeam\": {\n \"name\": \"Chiefs\",\n \"displayName\": \"Kansas City Chiefs\",\n \"color\": \"BE1415\",\n \"venue\": {\n \"id\": \"3622\"\n },\n \"alternateColor\": \"e31837\",\n \"shortDisplayName\": \"Chiefs\",\n \"abbreviation\": \"KC\",\n \"logo\": \"https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/kc.png\",\n \"isActive\": true,\n \"location\": \"Kansas City\",\n \"id\": \"12\",\n \"links\": [\n {\n \"text\": \"Clubhouse\",\n \"href\": \"https://www.espn.com/nfl/team/_/name/kc/kansas-city-chiefs\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/roster/_/name/kc/kansas-city-chiefs\",\n \"text\": \"Roster\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/stats/_/name/kc/kansas-city-chiefs\",\n \"text\": \"Statistics\"\n },\n {\n \"text\": \"Schedule\",\n \"href\": \"https://www.espn.com/nfl/team/schedule/_/name/kc\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/photos/_/name/kc\",\n \"text\": \"photos\"\n },\n {\n \"text\": \"Scores\",\n \"href\": \"sportscenter://x-callback-url/showClubhouse?uid=s:20~l:28~t:12§ion=scores\"\n },\n {\n \"text\": \"Draft Picks\",\n \"href\": \"http://www.espn.com/nfl/draft/teams/_/name/kc/kansas-city-chiefs\"\n },\n {\n \"text\": \"Transactions\",\n \"href\": \"https://www.espn.com/nfl/team/transactions/_/name/kc\"\n },\n {\n \"text\": \"Injuries\",\n \"href\": \"https://www.espn.com/nfl/team/injuries/_/name/kc\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/depth/_/name/kc\",\n \"text\": \"Depth Chart\"\n }\n ]\n },\n \"competitions\": [\n {\n \"geoBroadcasts\": [\n {\n \"region\": \"us\",\n \"lang\": \"en\",\n \"type\": {\n \"id\": \"1\",\n \"shortName\": \"TV\"\n },\n \"media\": {\n \"shortName\": \"CBS\"\n },\n \"market\": {\n \"id\": \"1\",\n \"type\": \"National\"\n }\n },\n {\n \"media\": {\n \"shortName\": \"ESPNDP\"\n },\n \"lang\": \"es\",\n \"market\": {\n \"id\": \"1\",\n \"type\": \"National\"\n },\n \"region\": \"us\",\n \"type\": {\n \"shortName\": \"TV\",\n \"id\": \"1\"\n }\n }\n ],\n \"leaders\": [\n {\n \"shortDisplayName\": \"PASS\",\n \"displayName\": \"Passing Leader\",\n \"name\": \"passingYards\",\n \"leaders\": [\n {\n \"value\": 270,\n \"displayValue\": \"26-49, 270 YDS, 2 INT\",\n \"team\": {\n \"id\": \"12\"\n },\n \"athlete\": {\n \"displayName\": \"Patrick Mahomes\",\n \"position\": {\n \"abbreviation\": \"QB\"\n },\n \"active\": true,\n \"headshot\": \"https://a.espncdn.com/i/headshots/nfl/players/full/3139477.png\",\n \"team\": {\n \"id\": \"12\"\n },\n \"links\": [\n {\n \"href\": \"http://www.espn.com/nfl/player/_/id/3139477/patrick-mahomes\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/stats/_/id/3139477/patrick-mahomes\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/splits/_/id/3139477/patrick-mahomes\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/gamelog/_/id/3139477/patrick-mahomes\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/news/_/id/3139477/patrick-mahomes\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/bio/_/id/3139477/patrick-mahomes\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/_/id/3139477/patrick-mahomes\"\n }\n ],\n \"id\": \"3139477\",\n \"jersey\": \"15\",\n \"fullName\": \"Patrick Mahomes\",\n \"shortName\": \"P. Mahomes\"\n }\n }\n ],\n \"abbreviation\": \"PYDS\"\n },\n {\n \"leaders\": [\n {\n \"value\": 89,\n \"team\": {\n \"id\": \"27\"\n },\n \"athlete\": {\n \"shortName\": \"L. Fournette\",\n \"position\": {\n \"abbreviation\": \"RB\"\n },\n \"active\": true,\n \"displayName\": \"Leonard Fournette\",\n \"team\": {\n \"id\": \"27\"\n },\n \"id\": \"3115364\",\n \"links\": [\n {\n \"href\": \"http://www.espn.com/nfl/player/_/id/3115364/leonard-fournette\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/stats/_/id/3115364/leonard-fournette\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/splits/_/id/3115364/leonard-fournette\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/gamelog/_/id/3115364/leonard-fournette\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/news/_/id/3115364/leonard-fournette\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/bio/_/id/3115364/leonard-fournette\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/_/id/3115364/leonard-fournette\"\n }\n ],\n \"fullName\": \"Leonard Fournette\",\n \"jersey\": \"7\",\n \"headshot\": \"https://a.espncdn.com/i/headshots/nfl/players/full/3115364.png\"\n },\n \"displayValue\": \"16 CAR, 89 YDS, 1 TD\"\n }\n ],\n \"name\": \"rushingYards\",\n \"displayName\": \"Rushing Leader\",\n \"shortDisplayName\": \"RUSH\",\n \"abbreviation\": \"RYDS\"\n },\n {\n \"abbreviation\": \"RECYDS\",\n \"leaders\": [\n {\n \"value\": 133,\n \"displayValue\": \"10 REC, 133 YDS\",\n \"team\": {\n \"id\": \"12\"\n },\n \"athlete\": {\n \"jersey\": \"87\",\n \"headshot\": \"https://a.espncdn.com/i/headshots/nfl/players/full/15847.png\",\n \"fullName\": \"Travis Kelce\",\n \"links\": [\n {\n \"href\": \"http://www.espn.com/nfl/player/_/id/15847/travis-kelce\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/stats/_/id/15847/travis-kelce\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/splits/_/id/15847/travis-kelce\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/gamelog/_/id/15847/travis-kelce\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/news/_/id/15847/travis-kelce\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/bio/_/id/15847/travis-kelce\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/player/_/id/15847/travis-kelce\"\n }\n ],\n \"shortName\": \"T. Kelce\",\n \"team\": {\n \"id\": \"12\"\n },\n \"id\": \"15847\",\n \"position\": {\n \"abbreviation\": \"TE\"\n },\n \"displayName\": \"Travis Kelce\",\n \"active\": true\n }\n }\n ],\n \"displayName\": \"Receiving Leader\",\n \"shortDisplayName\": \"REC\",\n \"name\": \"receivingYards\"\n }\n ],\n \"timeValid\": true,\n \"recent\": false,\n \"venue\": {\n \"id\": \"3886\",\n \"fullName\": \"Raymond James Stadium\",\n \"address\": {\n \"city\": \"Tampa\",\n \"state\": \"FL\"\n },\n \"indoor\": false,\n \"capacity\": 65618\n },\n \"status\": {\n \"displayClock\": \"0:00\",\n \"type\": {\n \"description\": \"Final\",\n \"state\": \"post\",\n \"name\": \"STATUS_FINAL\",\n \"shortDetail\": \"Final\",\n \"id\": \"3\",\n \"completed\": true,\n \"detail\": \"Final\"\n },\n \"period\": 4\n },\n \"attendance\": 24835,\n \"conferenceCompetition\": false,\n \"id\": \"401220403\",\n \"neutralSite\": true,\n \"startDate\": \"2021-02-07T17:30:00-06:00\",\n \"notes\": [\n {\n \"type\": \"event\",\n \"headline\": \"Super Bowl LV\"\n }\n ],\n \"broadcasts\": [\n {\n \"names\": [\n \"CBS\",\n \"ESPNDP\"\n ],\n \"market\": \"national\"\n }\n ],\n \"type\": {\n \"id\": \"1\",\n \"abbreviation\": \"STD\"\n },\n \"competitors\": [\n {\n \"score\": \"31\",\n \"records\": [\n {\n \"name\": \"All Splits\",\n \"abbreviation\": \"Any\",\n \"summary\": \"11-5\",\n \"type\": \"total\"\n },\n {\n \"type\": \"home\",\n \"name\": \"Home\",\n \"summary\": \"5-3\"\n },\n {\n \"name\": \"Road\",\n \"type\": \"road\",\n \"summary\": \"6-2\"\n }\n ],\n \"id\": \"27\",\n \"team\": {\n \"abbreviation\": \"TB\",\n \"location\": \"Tampa Bay\",\n \"isActive\": true,\n \"color\": \"A80D08\",\n \"venue\": {\n \"id\": \"3886\"\n },\n \"id\": \"27\",\n \"displayName\": \"Tampa Bay Buccaneers\",\n \"shortDisplayName\": \"Buccaneers\",\n \"alternateColor\": \"34302b\",\n \"logo\": \"https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/tb.png\",\n \"name\": \"Buccaneers\",\n \"links\": [\n {\n \"text\": \"Clubhouse\",\n \"href\": \"https://www.espn.com/nfl/team/_/name/tb/tampa-bay-buccaneers\"\n },\n {\n \"text\": \"Roster\",\n \"href\": \"http://www.espn.com/nfl/team/roster/_/name/tb/tampa-bay-buccaneers\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/stats/_/name/tb/tampa-bay-buccaneers\",\n \"text\": \"Statistics\"\n },\n {\n \"text\": \"Schedule\",\n \"href\": \"https://www.espn.com/nfl/team/schedule/_/name/tb\"\n },\n {\n \"text\": \"photos\",\n \"href\": \"https://www.espn.com/nfl/team/photos/_/name/tb\"\n },\n {\n \"href\": \"sportscenter://x-callback-url/showClubhouse?uid=s:20~l:28~t:27§ion=scores\",\n \"text\": \"Scores\"\n },\n {\n \"text\": \"Draft Picks\",\n \"href\": \"http://www.espn.com/nfl/draft/teams/_/name/tb/tampa-bay-buccaneers\"\n },\n {\n \"text\": \"Transactions\",\n \"href\": \"https://www.espn.com/nfl/team/transactions/_/name/tb\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/injuries/_/name/tb\",\n \"text\": \"Injuries\"\n },\n {\n \"text\": \"Depth Chart\",\n \"href\": \"https://www.espn.com/nfl/team/depth/_/name/tb\"\n }\n ]\n },\n \"type\": \"team\",\n \"homeAway\": \"home\",\n \"statistics\": [],\n \"linescores\": [\n {\n \"value\": 7\n },\n {\n \"value\": 14\n },\n {\n \"value\": 10\n },\n {\n \"value\": 0\n }\n ],\n \"winner\": true,\n \"order\": 0\n },\n {\n \"statistics\": [],\n \"score\": \"9\",\n \"homeAway\": \"away\",\n \"id\": \"12\",\n \"linescores\": [\n {\n \"value\": 3\n },\n {\n \"value\": 3\n },\n {\n \"value\": 3\n },\n {\n \"value\": 0\n }\n ],\n \"order\": 1,\n \"type\": \"team\",\n \"winner\": false,\n \"team\": {\n \"id\": \"12\",\n \"logo\": \"https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/kc.png\",\n \"location\": \"Kansas City\",\n \"abbreviation\": \"KC\",\n \"links\": [\n {\n \"text\": \"Clubhouse\",\n \"href\": \"https://www.espn.com/nfl/team/_/name/kc/kansas-city-chiefs\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/roster/_/name/kc/kansas-city-chiefs\",\n \"text\": \"Roster\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/stats/_/name/kc/kansas-city-chiefs\",\n \"text\": \"Statistics\"\n },\n {\n \"text\": \"Schedule\",\n \"href\": \"https://www.espn.com/nfl/team/schedule/_/name/kc\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/photos/_/name/kc\",\n \"text\": \"photos\"\n },\n {\n \"href\": \"sportscenter://x-callback-url/showClubhouse?uid=s:20~l:28~t:12§ion=scores\",\n \"text\": \"Scores\"\n },\n {\n \"text\": \"Draft Picks\",\n \"href\": \"http://www.espn.com/nfl/draft/teams/_/name/kc/kansas-city-chiefs\"\n },\n {\n \"text\": \"Transactions\",\n \"href\": \"https://www.espn.com/nfl/team/transactions/_/name/kc\"\n },\n {\n \"text\": \"Injuries\",\n \"href\": \"https://www.espn.com/nfl/team/injuries/_/name/kc\"\n },\n {\n \"text\": \"Depth Chart\",\n \"href\": \"https://www.espn.com/nfl/team/depth/_/name/kc\"\n }\n ],\n \"isActive\": true,\n \"displayName\": \"Kansas City Chiefs\",\n \"shortDisplayName\": \"Chiefs\",\n \"color\": \"BE1415\",\n \"venue\": {\n \"id\": \"3622\"\n },\n \"alternateColor\": \"e31837\",\n \"name\": \"Chiefs\"\n },\n \"records\": [\n {\n \"summary\": \"14-2\",\n \"name\": \"All Splits\",\n \"abbreviation\": \"Any\",\n \"type\": \"total\"\n },\n {\n \"summary\": \"6-2\",\n \"name\": \"Home\",\n \"type\": \"home\"\n },\n {\n \"name\": \"Road\",\n \"summary\": \"8-0\",\n \"type\": \"road\"\n }\n ]\n }\n ]\n }\n ],\n \"id\": \"401220403\",\n \"homeTeam\": {\n \"displayName\": \"Tampa Bay Buccaneers\",\n \"venue\": {\n \"id\": \"3886\"\n },\n \"id\": \"27\",\n \"color\": \"A80D08\",\n \"abbreviation\": \"TB\",\n \"name\": \"Buccaneers\",\n \"shortDisplayName\": \"Buccaneers\",\n \"logo\": \"https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/tb.png\",\n \"isActive\": true,\n \"alternateColor\": \"34302b\",\n \"links\": [\n {\n \"href\": \"https://www.espn.com/nfl/team/_/name/tb/tampa-bay-buccaneers\",\n \"text\": \"Clubhouse\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/roster/_/name/tb/tampa-bay-buccaneers\",\n \"text\": \"Roster\"\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/stats/_/name/tb/tampa-bay-buccaneers\",\n \"text\": \"Statistics\"\n },\n {\n \"text\": \"Schedule\",\n \"href\": \"https://www.espn.com/nfl/team/schedule/_/name/tb\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/photos/_/name/tb\",\n \"text\": \"photos\"\n },\n {\n \"href\": \"sportscenter://x-callback-url/showClubhouse?uid=s:20~l:28~t:27§ion=scores\",\n \"text\": \"Scores\"\n },\n {\n \"text\": \"Draft Picks\",\n \"href\": \"http://www.espn.com/nfl/draft/teams/_/name/tb/tampa-bay-buccaneers\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/transactions/_/name/tb\",\n \"text\": \"Transactions\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/injuries/_/name/tb\",\n \"text\": \"Injuries\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/depth/_/name/tb\",\n \"text\": \"Depth Chart\"\n }\n ],\n \"location\": \"Tampa Bay\"\n },\n \"nflHomeTeamId\": \"tb\",\n \"name\": \"Kansas City Chiefs at Tampa Bay Buccaneers\",\n \"nflAwayTeamId\": \"kc\",\n \"shortName\": \"KC @ TB\",\n \"seasonWeekId\": \"2020-POST-4\"\n },\n \"seasonYear\": 2020,\n \"gameDetailId\": \"10160000-0585-01aa-36fc-5a38a4f1dbb9\",\n \"esbId\": \"2021020700\",\n \"homeTeamId\": \"tb\",\n \"seasonWeekNum\": 4,\n \"awayTeam\": {\n \"id\": \"10402310-a47e-10ea-7442-16b633633637\",\n \"conferenceFullName\": \"American Football Conference\",\n \"colors\": {\n \"tertiary\": \"#FFFFFF\",\n \"primary\": \"#E31837\",\n \"secondary\": \"#FFB612\"\n },\n \"logos\": {\n \"svg\": \"https://static.www.nfl.com/league/api/clubs/logos/KC.svg\",\n \"png\": \"https://static.www.nfl.com/league/api/clubs/logos/KC.png\"\n },\n \"teamId\": \"kc\",\n \"conferenceAbbr\": \"AFC\",\n \"teamType\": \"TEAM\",\n \"nflSlug\": \"kansas-city-chiefs\",\n \"fullName\": \"Kansas City Chiefs\",\n \"espnTeam\": {\n \"isActive\": true,\n \"abbreviation\": \"KC\",\n \"id\": \"12\",\n \"record\": {},\n \"nickname\": \"KC\",\n \"slug\": \"kansas-city-chiefs\",\n \"alternateColor\": \"e31837\",\n \"logos\": [\n {\n \"width\": 500,\n \"alt\": \"\",\n \"height\": 500,\n \"rel\": [\n \"full\",\n \"default\"\n ],\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500/kc.png\"\n },\n {\n \"width\": 500,\n \"height\": 500,\n \"rel\": [\n \"full\",\n \"dark\"\n ],\n \"alt\": \"\",\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500-dark/kc.png\"\n },\n {\n \"height\": 500,\n \"alt\": \"\",\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500/scoreboard/kc.png\",\n \"width\": 500,\n \"rel\": [\n \"full\",\n \"scoreboard\"\n ]\n },\n {\n \"href\": \"https://a.espncdn.com/i/teamlogos/nfl/500-dark/scoreboard/kc.png\",\n \"alt\": \"\",\n \"height\": 500,\n \"rel\": [\n \"full\",\n \"scoreboard\",\n \"dark\"\n ],\n \"width\": 500\n }\n ],\n \"location\": \"Kansas City\",\n \"color\": \"BE1415\",\n \"links\": [\n {\n \"language\": \"en-US\",\n \"rel\": [\n \"clubhouse\",\n \"desktop\",\n \"team\"\n ],\n \"isPremium\": false,\n \"href\": \"https://www.espn.com/nfl/team/_/name/kc/kansas-city-chiefs\",\n \"text\": \"Clubhouse\",\n \"shortText\": \"Clubhouse\",\n \"isExternal\": false\n },\n {\n \"href\": \"http://www.espn.com/nfl/team/roster/_/name/kc/kansas-city-chiefs\",\n \"language\": \"en-US\",\n \"isPremium\": false,\n \"isExternal\": false,\n \"rel\": [\n \"roster\",\n \"desktop\",\n \"team\"\n ],\n \"text\": \"Roster\",\n \"shortText\": \"Roster\"\n },\n {\n \"isExternal\": false,\n \"href\": \"http://www.espn.com/nfl/team/stats/_/name/kc/kansas-city-chiefs\",\n \"language\": \"en-US\",\n \"rel\": [\n \"stats\",\n \"desktop\",\n \"team\"\n ],\n \"isPremium\": false,\n \"text\": \"Statistics\",\n \"shortText\": \"Statistics\"\n },\n {\n \"isPremium\": false,\n \"rel\": [\n \"schedule\",\n \"desktop\",\n \"team\"\n ],\n \"shortText\": \"Schedule\",\n \"text\": \"Schedule\",\n \"language\": \"en-US\",\n \"isExternal\": false,\n \"href\": \"https://www.espn.com/nfl/team/schedule/_/name/kc\"\n },\n {\n \"href\": \"https://www.espn.com/nfl/team/photos/_/name/kc\",\n \"text\": \"photos\",\n \"isExternal\": false,\n \"isPremium\": false,\n \"rel\": [\n \"photos\",\n \"desktop\",\n \"team\"\n ],\n \"language\": \"en-US\",\n \"shortText\": \"photos\"\n },\n {\n \"isExternal\": false,\n \"language\": \"en-US\",\n \"rel\": [\n \"scores\",\n \"sportscenter\",\n \"app\",\n \"team\"\n ],\n \"shortText\": \"Scores\",\n \"isPremium\": false,\n \"href\": \"sportscenter://x-callback-url/showClubhouse?uid=s:20~l:28~t:12§ion=scores\",\n \"text\": \"Scores\"\n },\n {\n \"isPremium\": true,\n \"href\": \"http://www.espn.com/nfl/draft/teams/_/name/kc/kansas-city-chiefs\",\n \"text\": \"Draft Picks\",\n \"rel\": [\n \"draftpicks\",\n \"desktop\",\n \"team\"\n ],\n \"isExternal\": false,\n \"language\": \"en-US\",\n \"shortText\": \"Draft Picks\"\n },\n {\n \"isExternal\": false,\n \"shortText\": \"Transactions\",\n \"text\": \"Transactions\",\n \"href\": \"https://www.espn.com/nfl/team/transactions/_/name/kc\",\n \"rel\": [\n \"transactions\",\n \"desktop\",\n \"team\"\n ],\n \"isPremium\": false,\n \"language\": \"en-US\"\n },\n {\n \"rel\": [\n \"injuries\",\n \"desktop\",\n \"team\"\n ],\n \"isPremium\": false,\n \"language\": \"en-US\",\n \"shortText\": \"Injuries\",\n \"isExternal\": false,\n \"text\": \"Injuries\",\n \"href\": \"https://www.espn.com/nfl/team/injuries/_/name/kc\"\n },\n {\n \"isPremium\": false,\n \"text\": \"Depth Chart\",\n \"rel\": [\n \"depthchart\",\n \"desktop\",\n \"team\"\n ],\n \"isExternal\": false,\n \"language\": \"en-US\",\n \"shortText\": \"Depth Chart\",\n \"href\": \"https://www.espn.com/nfl/team/depth/_/name/kc\"\n },\n {\n \"text\": \"Tickets\",\n \"isExternal\": true,\n \"language\": \"en\",\n \"rel\": [\n \"tickets\",\n \"desktop\",\n \"team\"\n ],\n \"href\": \"https://www.vividseats.com/nfl-football/kansas-city-chiefs-tickets.html?wsUser=717\",\n \"isPremium\": false\n }\n ],\n \"isAllStar\": false,\n \"displayName\": \"Kansas City Chiefs\",\n \"uid\": \"s:20~l:28~t:12\",\n \"name\": \"Chiefs\",\n \"shortDisplayName\": \"Chiefs\"\n },\n \"location\": \"Kansas City\",\n \"url\": {\n \"espn\": {\n \"schedule\": \"https://www.espn.com/nfl/team/schedule/_/name/kc\",\n \"injuries\": \"https://www.espn.com/nfl/team/injuries/_/name/kc\",\n \"depthChart\": \"https://www.espn.com/nfl/team/depth/_/name/kc\",\n \"transactions\": \"https://www.espn.com/nfl/team/transactions/_/name/kc\",\n \"roster\": \"https://www.espn.com/nfl/team/roster/_/name/kc\",\n \"teamStats\": \"https://www.espn.com/nfl/team/stats/_/type/team/name/kc\",\n \"stats\": \"https://www.espn.com/nfl/team/stats/_/name/kc\",\n \"teamStatsHistory\": \"https://www.espn.com/nfl/team/stats/_/type/team/name/kc/season/{seasonYear}/seasontype/2\",\n \"team\": \"https://www.espn.com/nfl/team/_/name/kc\"\n },\n \"nfl\": {\n \"stats\": \"https://www.nfl.com/teams/kansas-city-chiefs/stats\",\n \"roster\": \"https://www.nfl.com/teams/kansas-city-chiefs/roster\",\n \"team\": \"https://www.nfl.com/teams/kansas-city-chiefs\"\n }\n },\n \"venues\": [\n {\n \"id\": \"00081552-5c92-a7d0-fa55-fc0bb887fb88\",\n \"name\": \"GEHA Field at Arrowhead Stadium\"\n }\n ],\n \"abbreviation\": \"kc\",\n \"currentLogo\": \"https://static.www.nfl.com/{formatInstructions}/league/api/clubs/logos/KC\",\n \"divisionFullName\": \"AFC West\",\n \"espnTeamId\": \"kc\",\n \"nickName\": \"Chiefs\",\n \"league\": \"National Football League\"\n }\n }\n]"; var obj = SharpObject.LoadJsonString(json); var longTest = obj.GetInt("Array/gameDetail/homePointsQ1"); //Assert.IsTrue(true); } catch (Exception ex) { Assert.Fail(ex.Message); throw; } }
public void GetStringTest() { try { var obj = new SharpObject(); obj["string"] = "test"; obj["int"] = 3; var i = obj.GetString("int"); Assert.IsNotNull(i); } catch (Exception ex) { Assert.Fail(ex.Message); throw; } }
public List <SharpObject> GetColumnMapping(string path) { SharpNodeMap result; if (!_mapSets.TryGetValue(path, out result)) { return(new List <SharpObject>()); } return(result.Columns.Select(x => SharpObject.Copy(new { x.FieldName, x.Width, x.Offset, })).ToList()); }
internal void OnMemberChanged(SharpNodeRow row, SharpObject source, string fieldname, object value) { _updateRows[row] = source; }
public void DeleteOnSubmit(SharpObject item) { _rows.Remove(item.GetRow()); }
public SharpObjectPath(string path, object value) { Path = path; Value = SharpObject.Copy(value); }
public virtual SharpObject GetObject(string source) { // TODO: Add option to use packed+collapsed rows for faster reading when only a few columns are needed if (ColumnWidths.Count == 0) { return(new SharpObject()); } var column = 0; var width = ColumnWidths[column]; var sb = new StringBuilder(); var result = new SharpObject(); foreach (var c in source) { sb.Append(c); width--; if (width == 0) { var field = GetColumnName(ColumnNames[column]); var value = GetColumnValue(ColumnNames[column], sb.ToString()); if (IncludeEmptyFields || (value != null && (!(value is string) || !string.IsNullOrEmpty(value.ToString())))) { var parts = field.Split('/').ToList(); StringBuilder path = new StringBuilder(); for (int i = 0; i < parts.Count - 1; i++) { if (path.Length > 0) { path.Append("/"); } path.Append(parts[i]); var p = path.ToString(); if (!result.ContainsKey(p)) { result[p] = new SharpObject(); } } if (result.ContainsKey(field)) { result.Add(field, value); } else { result[field] = value; } } column++; if (column >= ColumnWidths.Count) { break; } width = ColumnWidths[column]; sb.Clear(); } } return(result); }
private SharpObject ApplyMap(SharpObject map, SharpObject record, SharpObject context) { var obj = new SharpObject(); foreach (var item in map) { if (item.Value is SharpObject) { obj[item.Key] = ApplyMap((SharpObject)item.Value, record, context); } else if (item.Value is SharpObjectList) { foreach (var child in (SharpObjectList)item.Value) { obj.Add(item.Key, ApplyMap(child, record, context)); } } else { if (item.Value is string) { object fieldValue = record.Format((string)item.Value); string stringValue = fieldValue.ToString(); if (SharpObject.IsFormatRequired(stringValue)) { fieldValue = obj.Format(stringValue); stringValue = fieldValue.ToString(); } if (SharpObject.IsFormatRequired(stringValue)) { fieldValue = null; stringValue = ""; } var fieldName = item.Key; var fieldParts = fieldName.Split('_'); if (fieldParts.Length == 2) { var fieldType = fieldParts[1].ToLower(); switch (fieldType) { case "bool": fieldName = fieldParts[0]; if (string.IsNullOrEmpty(stringValue)) { fieldValue = false; } else if (stringValue == "0" || stringValue == "1") { fieldValue = stringValue == "1"; } else if (stringValue.StartsWith("y", StringComparison.OrdinalIgnoreCase) || stringValue.StartsWith("n", StringComparison.OrdinalIgnoreCase)) { fieldValue = stringValue.StartsWith("y", StringComparison.OrdinalIgnoreCase); } else { fieldValue = Convert.ToBoolean(stringValue); } break; case "int": fieldName = fieldParts[0]; fieldValue = Convert.ToInt32(stringValue); break; case "long": fieldName = fieldParts[0]; fieldValue = Convert.ToInt64(stringValue); break; case "datetime": fieldName = fieldParts[0]; fieldValue = Convert.ToDateTime(stringValue); break; case "decimal": fieldName = fieldParts[0]; fieldValue = Convert.ToDecimal(stringValue); break; case "list": fieldName = fieldParts[0]; fieldValue = EncodedString.ParseList(stringValue); break; } } obj[fieldName] = fieldValue; } else { obj[item.Key] = item.Value; } } } return(obj); }
public void LoadMap(SharpObject map) { map.CopyTo(this); Map = map.GetMemberObject(RootNode, o => o); }
internal SharpObjectDynamic(SharpObject obj) { _obj = obj; }
public SharpObjectPathSet(string path, IEnumerable <object> values) { Path = path; Values = values.Select(x => SharpObject.Copy(x)); }
public static SharpObject AsSharpObject(this object obj) { return(SharpObject.Copy(obj).Clone()); }
public SharpObjectPath(string path, SharpObject value) { Path = path; Value = value; }