- XamlPatterns_v1.1.0.0.zip
- Controls
- Core
- docu
- Program
- Pub
- Desktop.Debug
- Itenso.Community.XamlPatterns.Controls.dll
- Itenso.Community.XamlPatterns.dll
- Desktop.Release
- Itenso.Community.XamlPatterns.Controls.dll
- Itenso.Community.XamlPatterns.dll
- Silverlight.Debug
- Itenso.Community.XamlPatterns.Controls.dll
- Itenso.Community.XamlPatterns.dll
- Silverlight.Release
- Itenso.Community.XamlPatterns.Controls.dll
- Itenso.Community.XamlPatterns.dll
- WindowsPhone.Debug
- Itenso.Community.XamlPatterns.Controls.dll
- Itenso.Community.XamlPatterns.dll
- WindowsPhone.Release
- Itenso.Community.XamlPatterns.Controls.dll
- Itenso.Community.XamlPatterns.dll
- XamlPatterns.Desktop.sln
- XamlPatterns.Desktop.suo
- XamlPatterns.Silverlight.sln
- XamlPatterns.Silverlight.suo
- XamlPatterns.WindowsPhone.sln
- XamlPatterns.WindowsPhone.suo
|
// -- FILE ------------------------------------------------------------------
// name : HierarchicalItemModel.cs
// project : Itenso Community
// created : Jani Giannoudis - 2012.05.05
// language : c#
// environment: .NET 4.0
// copyright : (c) 2004-2012 by Itenso GmbH, Switzerland
// --------------------------------------------------------------------------
using System;
using System.Collections.Generic;
namespace Itenso.Community.XamlPatterns.Presentation.Dependency
{
// ------------------------------------------------------------------------
public abstract class HierarchicalItemModel<TItemCollection, TItem> : ItemModel, IHierarchicalItemModel<TItemCollection, TItem>
where TItemCollection : class, ICollection<TItem>, new()
where TItem : IItemModel, IHierarchicalItemModel<TItemCollection, TItem>
{
// ----------------------------------------------------------------------
protected HierarchicalItemModel()
{
} // HierarchicalItemModel
// ----------------------------------------------------------------------
protected HierarchicalItemModel( TItem parent )
{
this.parent = parent;
} // HierarchicalItemModel
// ----------------------------------------------------------------------
public TItem Parent
{
get { return parent; }
} // Parent
// ----------------------------------------------------------------------
public bool HasChildren
{
get { return children != null; }
} // HasChildren
// ----------------------------------------------------------------------
public TItemCollection Children
{
get
{
if ( children == null )
{
children = new TItemCollection();
if ( children is IDisposable )
{
RegisterDisposable( children as IDisposable );
}
}
return children;
}
} // Children
// ----------------------------------------------------------------------
public int Count
{
get { return children != null ? children.Count : 0; }
} // Count
// ----------------------------------------------------------------------
public virtual bool IsRoot
{
get { return Equals( parent, default( TItem ) ); }
} // IsRoot
// ----------------------------------------------------------------------
protected override void Dispose( bool disposing )
{
if ( disposing && children is IDisposable )
{
((IDisposable)children).Dispose();
}
base.Dispose( disposing );
} // Dispose
// ----------------------------------------------------------------------
// members
private readonly TItem parent;
private TItemCollection children;
} // class HierarchicalItemModel
} // namespace Itenso.Community.XamlPatterns.Presentation.Dependency
// -- EOF -------------------------------------------------------------------
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
👨 Senior .NET Software Engineer
🚀 My Open Source Projects
-
Time Period Library 👉
GitHub
-
Payroll Engine 👉
GitHub
Feedback and contributions are welcome.