Foodolini.BusinessLogic.Ingredient.NutritionDictionary Class Reference

A mutable dictionary of Nutrients and amounts as System.Double. More...

List of all members.

Classes

class  NutritionDefinitionCollection
class  NutritionValueCollection

Public Member Functions

 NutritionDictionary (long foodDescriptionId)
 Create an instance of NutritionDictionary for a specific FoodDescription.
void Save (long foodDescriptionId)
 Save these associations for a FoodDescription.
void Delete (long foodDescriptionId)
 Delete the database representation of this NutritionDictionary.
void Add (Nutrient key, double value)
 Add a NutiontialValue to the dictionary.
bool ContainsKey (Nutrient key)
 Check if the dictionary contains a NutritionalValue for a specific Nutrient.
bool Remove (Nutrient key)
bool TryGetValue (Nutrient key, out double value)
bool TryGetValue (long id, out double value)
IEnumerator< KeyValuePair
< Nutrient, double > > 
GetEnumerator ()
void Add (KeyValuePair< Nutrient, double > item)
void Clear ()
bool Contains (KeyValuePair< Nutrient, double > item)
void CopyTo (KeyValuePair< Nutrient, double >[] array, int arrayIndex)
bool Remove (KeyValuePair< Nutrient, double > item)

Properties

double this [Nutrient key] [get, set]
ICollection< NutrientKeys [get]
ICollection< double > Values [get]
int Count [get]
bool IsReadOnly [get]

Private Member Functions

void SetValue (long defId, double amount)
 Set the amount of a NutrionalDefinition.
System.Collections.IEnumerator
System.Collections.IEnumerable. 
GetEnumerator ()

Private Attributes

Dictionary< long,
NutritionalValue
cachedValues = new Dictionary<long, NutritionalValue>()
 Cached NutitionalValues.
Dictionary< long,
NutritionalValue
changedValues = new Dictionary<long, NutritionalValue>()
 Changed or added NutritionalValues.
Dictionary< long,
NutritionalValue
deletedValues = new Dictionary<long, NutritionalValue>()
 Deleted NutritionalValues.

Detailed Description

A mutable dictionary of Nutrients and amounts as System.Double.

This dictionary is associated with a specific FoodDescription row, it cannot be used to save the same associations another, in the database existing, FoodDescription row. As it will fail to update/delete any associates it might have in the database. However, it can be used to give a not in the database existing FoodDescription row, the same associations as another FoodDescription row.

This dictionary is implemented to minimize then amount of database requests needed to load and save NutritionalValues, and thus optimize the performance.

Definition at line 25 of file Ingredient.NutritionDictionary.cs.


Constructor & Destructor Documentation

Foodolini.BusinessLogic.Ingredient.NutritionDictionary.NutritionDictionary ( long  foodDescriptionId  ) 

Create an instance of NutritionDictionary for a specific FoodDescription.

Parameters:
foodDescriptionId Identifier of FoodDescription row to created an instance for, 0 if it's a new row.

Definition at line 53 of file Ingredient.NutritionDictionary.cs.


Member Function Documentation

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Add ( KeyValuePair< Nutrient, double >  item  ) 

Definition at line 398 of file Ingredient.NutritionDictionary.cs.

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Add ( Nutrient  key,
double  value 
)

Add a NutiontialValue to the dictionary.

This will override any other existing entry for the Nutrient, if such is present.

Definition at line 188 of file Ingredient.NutritionDictionary.cs.

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Clear (  ) 

Definition at line 402 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Contains ( KeyValuePair< Nutrient, double >  item  ) 

Definition at line 411 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.ContainsKey ( Nutrient  key  ) 

Check if the dictionary contains a NutritionalValue for a specific Nutrient.

Parameters:
key A Nutrient to search for.
Returns:
True, if it contains a NutritionalValue for the Nutrient

Definition at line 201 of file Ingredient.NutritionDictionary.cs.

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.CopyTo ( KeyValuePair< Nutrient, double >[]  array,
int  arrayIndex 
)

Definition at line 416 of file Ingredient.NutritionDictionary.cs.

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Delete ( long  foodDescriptionId  ) 

Delete the database representation of this NutritionDictionary.

Parameters:
foodDescriptionId A System.Int64

Definition at line 118 of file Ingredient.NutritionDictionary.cs.

System.Collections.IEnumerator System.Collections.IEnumerable. Foodolini.BusinessLogic.Ingredient.NutritionDictionary.GetEnumerator (  )  [private]

Definition at line 391 of file Ingredient.NutritionDictionary.cs.

IEnumerator<KeyValuePair<Nutrient, double> > Foodolini.BusinessLogic.Ingredient.NutritionDictionary.GetEnumerator (  ) 

Definition at line 384 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Remove ( KeyValuePair< Nutrient, double >  item  ) 

Definition at line 423 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Remove ( Nutrient  key  ) 

Definition at line 205 of file Ingredient.NutritionDictionary.cs.

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Save ( long  foodDescriptionId  ) 

Save these associations for a FoodDescription.

This will save the NutritrionalValues for a specific FoodDescription, note that existing NutritrionalValues associated with this FoodDescription will only be overwritten, if this NutritionalDictionary was created specifically for this FoodDescription.

Parameters:
foodDescriptionId FoodDescriptionId to associate these NutritionalValues with.

Definition at line 72 of file Ingredient.NutritionDictionary.cs.

void Foodolini.BusinessLogic.Ingredient.NutritionDictionary.SetValue ( long  defId,
double  amount 
) [private]

Set the amount of a NutrionalDefinition.

Parameters:
defId Id of the NutrionalDefinition
amount Amount of the NutrionalDefinition

Definition at line 158 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.TryGetValue ( long  id,
out double  value 
)

Definition at line 228 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.TryGetValue ( Nutrient  key,
out double  value 
)

Definition at line 224 of file Ingredient.NutritionDictionary.cs.


Member Data Documentation

Cached NutitionalValues.

A NutritionalValue should only exists in either cachedValues, changedValues or deletedValues. And should never exist in more than one, when not operating on the object. (This is an important class invariant)

Definition at line 35 of file Ingredient.NutritionDictionary.cs.

Changed or added NutritionalValues.

Definition at line 40 of file Ingredient.NutritionDictionary.cs.

Deleted NutritionalValues.

Definition at line 45 of file Ingredient.NutritionDictionary.cs.


Property Documentation

int Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Count [get]

Definition at line 437 of file Ingredient.NutritionDictionary.cs.

bool Foodolini.BusinessLogic.Ingredient.NutritionDictionary.IsReadOnly [get]

Definition at line 441 of file Ingredient.NutritionDictionary.cs.

ICollection<Nutrient> Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Keys [get]

Definition at line 311 of file Ingredient.NutritionDictionary.cs.

double Foodolini.BusinessLogic.Ingredient.NutritionDictionary.this[Nutrient key] [get, set]

Definition at line 242 of file Ingredient.NutritionDictionary.cs.

ICollection<double> Foodolini.BusinessLogic.Ingredient.NutritionDictionary.Values [get]

Definition at line 378 of file Ingredient.NutritionDictionary.cs.


The documentation for this class was generated from the following file:

Foodolini 1.0.0 Documentation, generated with DoxyGen.