// 假设 MetaData 类的定义
class MetaData {
    // 这里可以添加 MetaData 类的属性和方法
}

class AttachProperty {
    private static attachedProperties: WeakMap<object, { [key: string]: any }> = new WeakMap();

    // Title 附加属性
    public static getTitle(obj: object): string {
        return AttachProperty.getAttachedValue(obj, "Title");
    }

    public static setTitle(obj: object, value: string): void {
        AttachProperty.setAttachedValue(obj, "Title", value);
    }

    // Tag 附加属性
    public static getTag(obj: object): string {
        return AttachProperty.getAttachedValue(obj, "Tag");
    }

    public static setTag(obj: object, value: string): void {
        AttachProperty.setAttachedValue(obj, "Tag", value);
    }

    // Rights 附加属性
    public static getRights(obj: object): string {
        return AttachProperty.getAttachedValue(obj, "Rights");
    }

    public static setRights(obj: object, value: string): void {
        AttachProperty.setAttachedValue(obj, "Rights", value);
    }

    // MetaData 附加属性
    public static getMetaData(obj: object): MetaData[] {
        return AttachProperty.getAttachedValue(obj, "MetaData");
    }

    public static setMetaData(obj: object, value: MetaData[]): void {
        AttachProperty.setAttachedValue(obj, "MetaData", value);
    }

    private static getAttachedValue(obj: object, key: string): any {
        const props = AttachProperty.attachedProperties.get(obj);
        return props ? props[key] : undefined;
    }

    private static setAttachedValue(obj: object, key: string, value: any): void {
        let props = AttachProperty.attachedProperties.get(obj);
        if (!props) {
            props = {};
            AttachProperty.attachedProperties.set(obj, props);
        }
        props[key] = value;
    }
}

export default AttachProperty;