// 模拟 DependencyObject
class DependencyObject {
    // 这里只是简单模拟，实际可能需要更复杂的实现
}

// 模拟 PageContainer
class PageContainer {
    // 这里只是简单模拟，实际可能需要更复杂的实现
}

// 模拟 Guid
class Guid {
    static Empty = new Guid();
}

// 存储附加属性的值
const attachedProperties = new WeakMap<DependencyObject, { [key: string]: any }>();

export class PageContainerHelper {
    private static readonly OwnerContainerKey = "OwnerContainer";
    private static readonly InstanceIdKey = "InstanceId";

    public static GetOwnerContainer(d: DependencyObject): PageContainer {
        const props = attachedProperties.get(d);
        return props ? props[this.OwnerContainerKey] as PageContainer : null;
    }

    public static SetOwnerContainer(d: DependencyObject, value: PageContainer): void {
        let props = attachedProperties.get(d);
        if (!props) {
            props = {};
            attachedProperties.set(d, props);
        }
        props[this.OwnerContainerKey] = value;
    }

    public static GetInstanceId(d: DependencyObject): Guid {
        const props = attachedProperties.get(d);
        return props ? props[this.InstanceIdKey] as Guid : Guid.Empty;
    }

    public static SetInstanceId(d: DependencyObject, value: Guid): void {
        let props = attachedProperties.get(d);
        if (!props) {
            props = {};
            attachedProperties.set(d, props);
        }
        props[this.InstanceIdKey] = value;
    }
}