HouseOver.THARM.Profile Class Reference

This class represents an interest profile for a customer. More...

Collaboration diagram for HouseOver.THARM.Profile:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Profile (Customer owner, int maxPrice, Type item)
 Constructs a new profile.
bool SaleWithinParameters (Sale sale)
 Determines if a sale matches the criteria of the profile.
 Profile (Customer owner, int maxPrice, Type item)
 Constructs a new profile.
bool SaleWithinParameters (Sale sale)
 Determines if a sale matches the criteria of the profile.

Static Public Member Functions

static bool MyInterfaceFilter (Type typeObj, Object criteriaObj)
 A static method for filtering interfaces in a Find() method.
static bool MyInterfaceFilter (Type typeObj, Object criteriaObj)
 A static method for filtering interfaces in a Find() method.

Properties

Type Item [get, set]
 Gets or sets the item.
int MaxPrice [get, set]
 Gets or sets the max price.
Customer Owner [get]
 Gets or sets the owner.
Dictionary< string, CheckChecks [get]
 Return the checks dictionary.
Dictionary< string, CheckChecks [get]
 Return the checks dictionary.

Private Member Functions

void CreateChecks (Type type)
 A private method for creating a new Check object which defines the criteria for matching this profile.
void CreateChecks (Type type)
 A private method for creating a new Check object which defines the criteria for matching this profile.

Private Attributes

int maxPrice
Type item
Customer owner
Dictionary< string, Checkchecks = new Dictionary<string, Check>()
Dictionary< string, Checkchecks = new Dictionary<string, Check>()

Detailed Description

This class represents an interest profile for a customer.

Definition at line 15 of file Profile.cs.


Constructor & Destructor Documentation

HouseOver.THARM.Profile.Profile ( Customer  owner,
int  maxPrice,
Type  item 
)

Constructs a new profile.

Parameters:
owner The owner of the profile. A customer.
maxPrice The maximum price the customer is willing to pay.
item Thet type of item a customer want. Eg. house or apartment.

Definition at line 28 of file Profile.cs.

00029         {
00030             this.owner = owner;
00031             this.maxPrice = maxPrice;
00032             this.item = item;
00033             CreateChecks(item);
00034         }

HouseOver.THARM.Profile.Profile ( Customer  owner,
int  maxPrice,
Type  item 
)

Constructs a new profile.

Parameters:
owner The owner of the profile. A customer.
maxPrice The maximum price the customer is willing to pay.
item Thet type of item a customer want. Eg. house or apartment.

Definition at line 28 of file Profile.cs.

00029         {
00030             this.owner = owner;
00031             this.maxPrice = maxPrice;
00032             this.item = item;
00033             CreateChecks(item);
00034         }


Member Function Documentation

void HouseOver.THARM.Profile.CreateChecks ( Type  type  )  [private]

A private method for creating a new Check object which defines the criteria for matching this profile.

Parameters:
type 

Definition at line 40 of file Profile.cs.

References HouseOver.THARM.Attributes.SaleCriteria.HumanReadableName.

00041         {
00042             checks.Clear(); // Clear the dictionary
00043             PropertyInfo[] pis = type.GetProperties(); // Get all properties for the given type.
00044             
00045             foreach (PropertyInfo pi in pis) // Loop through the found attributes (defined by the SaleCriteria
00046             // attribute) and get their type and add them to the dictionary. 
00047             {
00048                 SaleCriteria sc = (SaleCriteria)Attribute.GetCustomAttribute(pi, typeof(SaleCriteria));
00049                 if (sc == null)
00050                     continue;
00051 
00052                 if (pi.PropertyType.IsEnum)
00053                 {
00054                     checks.Add(pi.Name, new EnumCheck(pi.Name, sc.HumanReadableName == null 
00055                         ? pi.Name : sc.HumanReadableName, false, pi.PropertyType));  
00056                 } 
00057                 else if (pi.PropertyType.FindInterfaces(MyInterfaceFilter, "System.IComparable").Length > 0)
00058                 {
00059                     checks.Add(pi.Name,new ComparableCheck(pi.Name, sc.HumanReadableName == null 
00060                         ? pi.Name : sc.HumanReadableName, false, pi.PropertyType, null, null));
00061                 }
00062             }
00063         }

bool HouseOver.THARM.Profile.SaleWithinParameters ( Sale  sale  ) 

Determines if a sale matches the criteria of the profile.

Parameters:
sale The sale to match.
Returns:
A bool telling if the sale match.

Definition at line 70 of file Profile.cs.

References HouseOver.THARM.Sale.Item, and HouseOver.THARM.Sale.Price.

Referenced by HouseOver.THARM.RealtyManager.FindPotentialItems().

00071         {
00072             if (sale.Price > this.maxPrice)
00073                 return false;
00074 
00075             if(!item.IsAssignableFrom(sale.Item.GetType())) 
00076             {
00077                 return false;
00078             }
00079 
00080             foreach (Check c in Checks.Values)
00081             {
00082                 object retval = sale.Item.GetType().GetProperty(c.Name).GetValue(sale.Item, null);
00083                 if (!c.Verify(retval))
00084                 {
00085                     return false;
00086                 }
00087             }
00088 
00089             return true;
00090         }

Here is the caller graph for this function:

static bool HouseOver.THARM.Profile.MyInterfaceFilter ( Type  typeObj,
Object  criteriaObj 
) [static]

A static method for filtering interfaces in a Find() method.

Parameters:
typeObj Input type.
criteriaObj User data for verifying interfaces.
Returns:

Definition at line 98 of file Profile.cs.

00099         {
00100             if (typeObj.ToString() == criteriaObj.ToString())
00101                 return true;
00102             else
00103                 return false;
00104         }

void HouseOver.THARM.Profile.CreateChecks ( Type  type  )  [private]

A private method for creating a new Check object which defines the criteria for matching this profile.

Parameters:
type 

Definition at line 40 of file Profile.cs.

References HouseOver.THARM.Attributes.SaleCriteria.HumanReadableName.

00041         {
00042             checks.Clear(); // Clear the dictionary
00043             PropertyInfo[] pis = type.GetProperties(); // Get all properties for the given type.
00044             
00045             foreach (PropertyInfo pi in pis) // Loop through the found attributes (defined by the SaleCriteria
00046             // attribute) and get their type and add them to the dictionary. 
00047             {
00048                 SaleCriteria sc = (SaleCriteria)Attribute.GetCustomAttribute(pi, typeof(SaleCriteria));
00049                 if (sc == null)
00050                     continue;
00051 
00052                 if (pi.PropertyType.IsEnum)
00053                 {
00054                     checks.Add(pi.Name, new EnumCheck(pi.Name, sc.HumanReadableName == null 
00055                         ? pi.Name : sc.HumanReadableName, false, pi.PropertyType));  
00056                 } 
00057                 else if (pi.PropertyType.FindInterfaces(MyInterfaceFilter, "System.IComparable").Length > 0)
00058                 {
00059                     checks.Add(pi.Name,new ComparableCheck(pi.Name, sc.HumanReadableName == null 
00060                         ? pi.Name : sc.HumanReadableName, false, pi.PropertyType, null, null));
00061                 }
00062             }
00063         }

bool HouseOver.THARM.Profile.SaleWithinParameters ( Sale  sale  ) 

Determines if a sale matches the criteria of the profile.

Parameters:
sale The sale to match.
Returns:
A bool telling if the sale match.

Definition at line 70 of file Profile.cs.

References HouseOver.THARM.Sale.Item, and HouseOver.THARM.Sale.Price.

00071         {
00072             if (sale.Price > this.maxPrice)
00073                 return false;
00074 
00075             if(!item.IsAssignableFrom(sale.Item.GetType())) 
00076             {
00077                 return false;
00078             }
00079 
00080             foreach (Check c in Checks.Values)
00081             {
00082                 object retval = sale.Item.GetType().GetProperty(c.Name).GetValue(sale.Item, null);
00083                 if (!c.Verify(retval))
00084                 {
00085                     return false;
00086                 }
00087             }
00088 
00089             return true;
00090         }

static bool HouseOver.THARM.Profile.MyInterfaceFilter ( Type  typeObj,
Object  criteriaObj 
) [static]

A static method for filtering interfaces in a Find() method.

Parameters:
typeObj Input type.
criteriaObj User data for verifying interfaces.
Returns:

Definition at line 98 of file Profile.cs.

00099         {
00100             if (typeObj.ToString() == criteriaObj.ToString())
00101                 return true;
00102             else
00103                 return false;
00104         }


Member Data Documentation

int HouseOver::THARM.Profile::maxPrice [private]

Definition at line 17 of file Profile.cs.

Type HouseOver::THARM.Profile::item [private]

Definition at line 18 of file Profile.cs.

Customer HouseOver::THARM.Profile::owner [private]

Definition at line 19 of file Profile.cs.

Dictionary<string, Check> HouseOver.THARM.Profile.checks = new Dictionary<string, Check>() [private]

Definition at line 20 of file Profile.cs.

Dictionary<string, Check> HouseOver.THARM.Profile.checks = new Dictionary<string, Check>() [private]

Definition at line 20 of file Profile.cs.


Property Documentation

Type HouseOver::THARM.Profile::Item [get, set]

Gets or sets the item.

Definition at line 109 of file Profile.cs.

Referenced by HouseOver.THARM.RealtyManager.SetComparableCheck(), HouseOver.THARM.RealtyManager.SetEnumCheck(), HouseOver.THARM.RealtyManager.ShowProfile(), and HouseOver.THARM.RealtyManager.ShowProfileDetails().

int HouseOver::THARM.Profile::MaxPrice [get, set]

Gets or sets the max price.

Definition at line 113 of file Profile.cs.

Referenced by HouseOver.THARM.RealtyManager.ShowProfileDetails(), and HouseOver.THARM.RealtyManager.SortProfileByPrice().

Customer HouseOver::THARM.Profile::Owner [get]

Gets or sets the owner.

Definition at line 117 of file Profile.cs.

Referenced by HouseOver.THARM.RealtyManager.SetComparableCheck(), HouseOver.THARM.RealtyManager.SetEnumCheck(), HouseOver.THARM.RealtyManager.ShowProfile(), and HouseOver.THARM.RealtyManager.ShowProfileDetails().

Dictionary<string, Check> HouseOver.THARM.Profile.Checks [get]

Return the checks dictionary.

Definition at line 121 of file Profile.cs.

Referenced by HouseOver.THARM.RealtyManager.ShowProfileDetails().

Dictionary<string, Check> HouseOver.THARM.Profile.Checks [get]

Return the checks dictionary.

Definition at line 121 of file Profile.cs.


The documentation for this class was generated from the following files:
Generated on Wed Jan 10 03:43:00 2007 for THARM by  doxygen 1.5.1-p1