Problems with StockTraderRI in latest drop???

Jun 4, 2008 at 4:43 AM
Anyone else having problems running the StockTraderRI in the latest (12146) drop of Prism? I'm getting a module load exception I'm not really sure how to solve.
Jun 4, 2008 at 5:19 AM
Edited Jun 4, 2008 at 6:00 AM
This turned out the be caused by the date parsing in the News module...

PublishedDate = DateTime.Parse(newsItem.Attribute("PublishedDate").Value, CultureInfo.CurrentCulture)


the problem being that the dates in the data file are in an en-US, and my CurrentCulture is en-AU.

Not very international friendly code :)
Jun 5, 2008 at 3:43 PM
Edited Jun 5, 2008 at 3:59 PM
Hi jtango18, it's pretty easy to get around this problem, I can verify that the same problem was in the last two drops.

Open StockTraderRI.Modules.News/Services/NewsFeedService.cs

Add a static reference to the en-US culture.

    private static CultureInfo USCulture = new CultureInfo("en-US");

Replace

    PublishedDate = DateTime.Parse(newsItem.Attribute("PublishedDate").Value, CultureInfo.CurrentCulture),

With

    PublishedDate = DateTime.Parse(newsItem.Attribute("PublishedDate").Value, USCulture),

To the P&P guys maybe you could include this in the source so us Aussies don't see this problem on future drops?

I'm not sure about how to upload patches (is there a facility?) so here it is below.


Index: Source/StockTraderRI/StockTraderRI.Modules.News/Services/NewsFeedService.cs
===================================================================
--- Source/StockTraderRI/StockTraderRI.Modules.News/Services/NewsFeedService.cs	(revision 12352)
+++ Source/StockTraderRI/StockTraderRI.Modules.News/Services/NewsFeedService.cs	(working copy)
@@ -28,6 +28,7 @@
     public class NewsFeedService : INewsFeedService
     {
         readonly Dictionary<string, List<NewsArticle>> newsData = new Dictionary<string, List<NewsArticle>>();
+        private static CultureInfo USCulture = new CultureInfo("en-US");
 
         public NewsFeedService()
         {
@@ -41,7 +42,7 @@
                 }
                 newsData[tickerSymbol].Add(new NewsArticle()
                 {
-                    PublishedDate = DateTime.Parse(newsItem.Attribute("PublishedDate").Value, CultureInfo.CurrentCulture),
+                    PublishedDate = DateTime.Parse(newsItem.Attribute("PublishedDate").Value, USCulture),
                     Title = newsItem.Element("Title").Value,
                     Body = newsItem.Element("Body").Value,
                     IconUri = newsItem.Attribute("IconUri") != null ? newsItem.Attribute("IconUri").Value : null


-Brett
Jun 6, 2008 at 2:05 AM
Hey Brett,

Your solution is basically what I did to get around this. Thanks though :)

I definitely didn't have this problem with the last 2 drops though.

Justin
Jun 6, 2008 at 4:43 AM
Hey jtango, no worries. I had it in both 11609 and 12146, have now switched to the svn source hoping to possibly see any new movements early.

Can I ask how you're finding Prism? I'm a bit two sided with it, I think I'm struggling with it just a little, I always found CAB a little heavy to swallow and now while it's a smaller pill, still finding prism a little hard to swallow too. I hope as more guidance and samples come out it will make things a little easier for us.

The other thing is I totally get what WPF is trying to do, but how do you get the flexibility of WPF with compile time safety? I'm finding that most of my problems attribute to errors in my XAML that, due to disconnecting my UI from my model, there's no real XAML test coverage.

I shouldn't have posted this here, but just thought I'd see how someone closer to home is going.

-Brett.


jtango18 wrote:
Hey Brett,

Your solution is basically what I did to get around this. Thanks though :)

I definitely didn't have this problem with the last 2 drops though.

Justin