This repository has been archived by the owner on Sep 14, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Credit to @samsp Trying to merge and refactor :)
- Loading branch information
1 parent
baacb7d
commit 78afa2f
Showing
26 changed files
with
803 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=models_005Cincremental/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=services_005Cframework/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace Kliva.Models.Converters | ||
{ | ||
/// <summary> | ||
/// This will look at the fields of the athlete and will create an object based on those fields | ||
/// </summary> | ||
public class AthleteJsonConverter : JsonConverter | ||
{ | ||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) | ||
{ | ||
AthleteMeta athleteMeta; | ||
// Load JObject from stream | ||
JObject jObject = JObject.Load(reader); | ||
|
||
if (FieldExists("athlete_type", jObject)) | ||
{ | ||
athleteMeta = new Athlete(); | ||
} | ||
else if (FieldExists("firstname", jObject)) | ||
{ | ||
athleteMeta = new AthleteSummary(); | ||
} | ||
else | ||
{ | ||
athleteMeta = new AthleteMeta(); | ||
} | ||
|
||
// Populate the object properties | ||
serializer.Populate(jObject.CreateReader(), athleteMeta); | ||
|
||
return athleteMeta; | ||
} | ||
|
||
private bool FieldExists(string fieldName, JObject jObject) | ||
{ | ||
return jObject[fieldName] != null; | ||
} | ||
|
||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) | ||
{ | ||
serializer.Serialize(writer, value); | ||
} | ||
|
||
public override bool CanConvert(Type objectType) | ||
{ | ||
return (objectType == typeof(AthleteMeta)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/Kliva/Models/Incremental/ActivityIncrementalCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Kliva.Services.Interfaces; | ||
using Kliva.Helpers; | ||
|
||
namespace Kliva.Models | ||
{ | ||
public abstract class ActivityIncrementalCollection : CachedKeyedIncrementalLoadingBase | ||
{ | ||
private readonly IStravaService _stravaService; | ||
|
||
protected ActivityIncrementalCollection(IStravaService stravaService, ActivityFeedFilter cachename) | ||
: base(cachename) | ||
{ | ||
_stravaService = stravaService; | ||
} | ||
|
||
protected override async Task<List<object>> HydrateItems(string data) | ||
{ | ||
var results = await _stravaService.HydrateActivityData(data); | ||
//foreach( var item in from r in results where r.PhotoCount > 0 select r) // TODO review | ||
This comment has been minimized.
Sorry, something went wrong. |
||
// { | ||
|
||
// } | ||
return results.Cast<object>().ToList(); | ||
} | ||
} | ||
} |
Oops, something went wrong.
1 comment
on commit 78afa2f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not too familiar with the IoC pattern you are using for services, but this seems like a more consistent version of what I was trying to achieve.
Can be removed, I was playing with photos, to see which activities had them, but ran into the same issue with photos not being accessible anyway.