mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
64 lines
1.4 KiB
C#
64 lines
1.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace csharp.StrategyPatternExample
|
|
{
|
|
/// <summary>
|
|
/// Wrapper class to allow to create a context for every defined item and thus to be able to bind a strategy.
|
|
/// </summary>
|
|
public class ItemWrapperContext
|
|
{
|
|
#region Variables
|
|
|
|
private Item _item;
|
|
private List<ICategoryStrategy> listCategoryStrategies;
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public string Name
|
|
{
|
|
get { return this._item.Name; }
|
|
set { this._item.Name = value; }
|
|
}
|
|
|
|
public int Quality
|
|
{
|
|
get { return this._item.Quality; }
|
|
set { this._item.Quality = value; }
|
|
}
|
|
|
|
public int SellIn
|
|
{
|
|
get { return this._item.SellIn; }
|
|
set { this._item.SellIn = value; }
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
public ItemWrapperContext(Item item)
|
|
{
|
|
this._item = item;
|
|
|
|
listCategoryStrategies = CategoryStrategiesFactory.GetInstance().GetCategoryStrategies(item);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public void UpdateQuality()
|
|
{
|
|
foreach (ICategoryStrategy categoryStrategyItem in this.listCategoryStrategies)
|
|
{
|
|
categoryStrategyItem.Update(this._item);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|