00001 using System; 00002 using System.Collections.Generic; 00003 using System.Text; 00004 using HouseOver.THARM.Attributes; 00005 using System.Reflection; 00006 00007 namespace HouseOver.THARM 00008 { 00012 [Serializable] 00013 public abstract class Item : UniquelyIdentifiable 00014 { 00016 protected int postalCode; 00018 protected int area; 00019 00023 public Item() : base(UniquelyIdentifiable.NextID) { } 00024 00029 public Item(int id) : base(id) { } 00030 00037 public Item(int id, int postalCode, int area) : base(id) 00038 { 00039 this.postalCode = postalCode; 00040 this.area = area; 00041 } 00042 00047 public static List<Type> GetSearchableItems() 00048 { 00049 Assembly a = Assembly.GetAssembly(typeof(Item)); 00050 Module[] modules = a.GetModules(); 00051 List<Type> types = new List<Type>(); 00052 foreach (Module m in modules) 00053 { 00054 Type[] classes = m.FindTypes(delegate(Type t, object g) 00055 { 00056 if (t.GetCustomAttributes(typeof(SearchItems), false).Length > 0) 00057 return true; 00058 00059 return false; 00060 }, null); 00061 types.AddRange(classes); 00062 00063 } 00064 00065 return types; 00066 } 00067 00071 [SaleCriteria("Postal Code")] 00072 public int PostalCode { get { return postalCode; } set { postalCode = value; } } 00076 [SaleCriteria] 00077 public int Area { get { return area; } set { area = value; } } 00078 00079 00080 } 00081 }