forked from kievaltnet/kievaltnet
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
61 additions
and
53 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 |
---|---|---|
@@ -1,50 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Yaml.Serialization; | ||
using WebSite.Extensions; | ||
|
||
namespace WebSite.App.Speakers | ||
{ | ||
public class SpeakerProvider : IEnumerable<Speaker> | ||
{ | ||
private readonly List<Speaker> _speakers = new List<Speaker>(); | ||
|
||
public SpeakerProvider(DirectoryInfo dataFolder) | ||
{ | ||
var serializer = new YamlSerializer(); | ||
var profiles = dataFolder.GetFiles("*.yaml"); | ||
foreach (var profileFile in profiles) | ||
{ | ||
using (var reader = profileFile.OpenRead()) | ||
{ | ||
using WebSite.Extensions; | ||
|
||
namespace WebSite.App.Speakers | ||
{ | ||
public class SpeakerProvider : IEnumerable<Speaker> | ||
{ | ||
private readonly List<Speaker> _speakers = new List<Speaker>(); | ||
|
||
public SpeakerProvider(DirectoryInfo dataFolder) | ||
{ | ||
var serializer = new YamlSerializer(); | ||
var profiles = dataFolder.GetFiles("*.yaml"); | ||
foreach (var profileFile in profiles) | ||
{ | ||
using (var reader = profileFile.OpenRead()) | ||
{ | ||
var speaker = (Speaker)serializer.Deserialize(reader, typeof(Speaker))[0]; | ||
speaker.Id = profileFile.Name.SkipExtension(profileFile.Extension); | ||
if (string.IsNullOrEmpty(speaker.Avatar)) | ||
{ | ||
speaker.Avatar = speaker.Email.ToGravatarLink(); | ||
} | ||
|
||
_speakers.Add(speaker); | ||
} | ||
} | ||
_speakers.Sort((x, y) => x.FullName.CompareTo(y.FullName)); | ||
} | ||
|
||
public IEnumerator<Speaker> GetEnumerator() | ||
{ | ||
return _speakers.GetEnumerator(); | ||
} | ||
|
||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | ||
{ | ||
return this.GetEnumerator(); | ||
} | ||
|
||
public Speaker Get(string id) | ||
{ | ||
return this.First(x => x.Id == id); | ||
} | ||
} | ||
} | ||
|
||
_speakers.Add(speaker); | ||
} | ||
} | ||
_speakers.Sort((x, y) => x.FullName.CompareTo(y.FullName)); | ||
} | ||
|
||
public IEnumerator<Speaker> GetEnumerator() | ||
{ | ||
return _speakers.GetEnumerator(); | ||
} | ||
|
||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() | ||
{ | ||
return this.GetEnumerator(); | ||
} | ||
|
||
public Speaker Get(string id) | ||
{ | ||
return this.First(x => x.Id == id); | ||
} | ||
} | ||
} |
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