Views: 6.9K
Replies: 1
Archived
|
Magic number in the CustomerImageConverter class in Silverlight Patterns in Action.csprojWhat is the 91 in the following code?
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string size = (string)parameter; int id = int.Parse(value.ToString()); if (id > 91) id = 0; // New customers are getting the default silhouette icon. var uri = new Uri(HtmlPage.Document.DocumentUri, "Assets/Images/Customers/" + size + "/" + id + ".jpg"); return new BitmapImage(uri); } M S, Sep 01, 2010
|
|
Reply 1Indeed a magic number :-). The default database holds 91 customer records which is where the number comes from.
The Silverlight Patterns application supports adding a new customer, but not uploading images. So, this check ensures a default silhouette image for each new customer. Of course, a production type application would include the option to upload customer images and then the "if (id > 91)" condition would be removed. Hope this helps. Dan McMillan, Sep 01, 2010
|