Here is the design problem in pseudo example:

It is ASP.NET User control (UC) which uses the "Food" object as data source and this object has property FoodType - "Veg" || "Nonveg".

The user control changes UI display depending upon FoodType property. In code-behind class of User Control, some methods have same if/then/else condition: if(Food.FoodType == "Veg")... else ...

Here, I would like use State-like pattern such that code-behind class of User Control will contain two inner/nested classes, i.e. "VegFood" class and "NonvegFood" class. Now, lets say, NonvegFood class will contain its own logic implementation.

But having one interface, two instance classes (as nested) which will be used in this user control only, could be overdesign. In addition to that, UC does not have driver method where I can call related methods in one if block, like they are "DataBound" and "ItemCreated".

Still, is it possible to have State like pattern inside UC class? Probably two instance inner classes inside UC and somehow if I can delegate call to one of these inner class?

class UC : UserControl

{


class VegFood
{
string DisplayName
{
get
{
return "Rice";
}
}
}

class NonvegFood
{
string DisplayName
{
get
{
return "Chicken";
}
}
}

protected string DisplayName
{
get
{
return Instance.DisplayName;
}
}

/*********** MAGIC Property ****************/
private ? Instance
{
get
{
return ?;
}
}
}