// 模拟 TreeViewItem 类
class TreeViewItem {
    // 模拟 OverridesDefaultStyle 属性
    public OverridesDefaultStyle: boolean = false;
    // 模拟 ItemsControl 属性
    public static ItemsControlFromItemContainer(item: any): any {
        return item.parent;
    }
}

export class TreeViewListItem extends TreeViewItem {
    private _level: number = -1;
    // 模拟 parent 属性
    public parent: TreeViewListItem | null = null;

    /**
     * 获取层次等级
     */
    public get Level(): number {
        if (this._level === -1) {
            const parent = TreeViewItem.ItemsControlFromItemContainer(this) as TreeViewListItem;
            this._level = parent ? parent.Level + 1 : 0;
        }
        return this._level;
    }

    /**
     * 为子项创建容器
     */
    protected GetContainerForItemOverride(): TreeViewListItem {
        const li = new TreeViewListItem();
        li.OverridesDefaultStyle = true;
        li.parent = this;
        return li;
    }

    /**
     * 判断一个项是否为自身的容器
     */
    protected IsItemItsOwnContainerOverride(item: any): boolean {
        return item instanceof TreeViewListItem;
    }
}