Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace WcfFromConsole
- {
- public class Products
- {
- private static readonly Products _instance = new Products();
- private Products() { }
- public static Products Instance { get { return _instance; } }
- public List<Product> ProductList { get { return products; } }
- private List<Product> products = new List<Product>()
- {
- new Product() {ProductId=1,Name="test1" },
- new Product() {ProductId=2,Name="test2" }
- };
- public Product GetProduct(int id)
- {
- for (int i = 0; i < ProductList.Count; i++)
- {
- if (ProductList[i].ProductId == id)
- {
- return ProductList[i];
- }
- }
- return null;
- }
- }
- [DataContract]
- public class Product
- {
- [DataMember]
- public int ProductId { get; set; }
- [DataMember]
- public string Name { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement