I'd like to represent containers within containers and have created the following class structure:
public class ContainerLib<T>
{
/// <summary>
/// Generic container type
/// </summary>
public T Container { get; set; }
/// <summary>
/// Container type
/// </summary>
public Type ContainerType {
get { return ContainerType; }
set { value = typeof (T); }
}
/// <summary>
/// ContainerLib enum
/// May change to IList
/// </summary>
public IList<ContainerLib<T>> Containers { get; set; }
}
/// <summary>
/// Video container
/// </summary>
public class Container
{
/// <summary>
/// Container ID
/// </summary>
public int Id { get; set; }
public string Name { get; set; }
/// <summary>
/// Details about the physical location of this container
/// </summary>
public LocationDefinition LocationDefinition { get; set; }
/// <summary>
/// Type of container - {layout, perspective, source
/// </summary>
public string ContainerType { get; set; }
/// <summary>
/// List of containers
/// </summary>
public IList<ContainerLib<Container>> Containers { get; set; }
}
I'm a little stuck on how to implement this... if I'm even doing this correctly:
var containerLib = new ContainerLib<Container>
{
Container = new Container
{
Id = 1,
LocationDefinition = new LocationDefinition
{
WidthPixels = 100,
HeightPixels = 100,
NumColumns = 10,
NumRows = 10,
TopLeftX = 0,
TopLeftY = 0
},
ContainerType = "Layout"
}
};
containerLib.Containers = new List<ContainerLib<Container>>
{
// build nested structure here ../../../../
};
So I'd like to set add data to the structure, then iterate through it.
I found an efficient way of using a Dictionary
, but that's not what I'm looking for.
I added
public IList<ContainerLib<Container>> Containers { get; set; }
to Container
, and by doing that I'm wondering if I even need the ContainerLib<T>
anymore?
Assistance appreciated.