diff --git a/PolyFeed/FeedBuilder.cs b/PolyFeed/FeedBuilder.cs index 65c9bd1..9359efa 100644 --- a/PolyFeed/FeedBuilder.cs +++ b/PolyFeed/FeedBuilder.cs @@ -87,7 +87,16 @@ namespace PolyFeed : lastUpdatedNode.Attributes[source.EntryLastUpdatedAttribute].DeEntitizeValue ); } + + await feed.Write(nextItem); } } + + public string Render() + { + xml.Flush(); + xml.WriteEndDocument(); + return result.ToString(); + } } } diff --git a/PolyFeed/Program.cs b/PolyFeed/Program.cs index e45effd..41635c4 100644 --- a/PolyFeed/Program.cs +++ b/PolyFeed/Program.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Text.RegularExpressions; +using System.Threading.Tasks; using Nett; namespace PolyFeed @@ -79,19 +81,27 @@ namespace PolyFeed return 0; } - private static void run() + private static async Task run() { FeedSource feedSource = new FeedSource(); TomlTable config = Toml.ReadFile(settings.ConfigFilepath, TomlSettings.Create()); foreach (KeyValuePair item in config) { - string key = item.Key; + string key = Regex.Replace( + item.Key, + @"(^|_)[A-Za-z0-9]", + (match) => match.Value.Replace("_", "").ToUpper() + ); string value = item.Value.Get().Value; feedSource.GetType().GetProperty(value).SetValue( feedSource, value ); } + + FeedBuilder feedBuilder = new FeedBuilder(); + await feedBuilder.AddSource(feedSource); + return await feedBuilder.Render(); }