Technical Articles: Common Components™ - Immutable, Self-Referential Graphs: Why & How
|
|
|
|
|
Technical Articles: Common Components
|
2/10/2008 10:27 PM
|
|
view as a single page
Example: Circular Reference (incomplete)
using System;
using System.Collections;
using System.Collections.Generic;
using System.Xml;
public interface Strategy
{
void Process(object argument);
}
internal class UnwrapList : Strategy
{
private readonly Strategy _Whole;
public void Process(object argument)
{
IList argumentAsList;
try
{
argumentAsList = (IList)argument;
}
catch (InvalidCastException)
{
return;
}
foreach (object o in argumentAsList)
{
_Whole.Process(o);
}
}
}
Related Links:
Common Components
|
|
|
|