annotate SilverlightExampleApp/SilverlightExampleApp.Web/Factories/CountryFactory.cs @ 121:8f94475d3146 tip

final code
author stevenh7776
date Thu, 31 May 2012 15:35:26 +0100
parents 502f5f365649
children
rev   line source
49
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
1 
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
2 using System.Collections.Generic;
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
3 using System.Linq;
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
4 using SilverlightExampleApp.Interfaces.Models;
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
5 using SilverlightExampleApp.Web.Models;
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
6
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
7 namespace SilverlightExampleApp.Web.Factories
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
8 {
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
9 public class CountryFactory
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
10 {
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
11 private readonly static IList<ICountry> _countries = new List<ICountry>(7)
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
12 {
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
13 new Country() {Id = 1, Description = "England"},
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
14 new Country() {Id = 2, Description = "France"},
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
15 new Country() {Id = 3, Description = "Germany"},
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
16 new Country() {Id = 4, Description = "Italy"},
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
17 new Country() {Id = 5, Description = "Scotland"},
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
18 new Country() {Id = 6, Description = "Spain"},
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
19 new Country() {Id = 7, Description = "Wales"}
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
20 };
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
21
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
22 public static IList<ICountry> GetAll()
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
23 {
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
24 return _countries;
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
25 }
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
26
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
27 public static ICountry Get(int id)
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
28 {
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
29 return _countries.FirstOrDefault(t => id == t.Id);
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
30 }
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
31 }
502f5f365649 Initial load for Silverlight Example Application
Steven Hollidge <stevenhollidge@hotmail.com>
parents:
diff changeset
32 }