session_nub.ts 1.60 KiB
import { Nub } from "./nub";
/**
 * gestion d'un ensemble de propriétés (clé/valeur)
 */
export class Props {
    constructor(private _props: any = {}) { }
    public hasProperties(props: Props | {}): boolean {
        const keys = Object.keys(this._props);
        const p = props instanceof Props ? props.props : props;
        // if (keys.length != Object.keys(p).length)
        //     return false;
        for (const k of keys)
            if (this._props[k] !== p[k])
                return false;
        return true;
    public getPropValue(key: string): any {
        return this._props[key];
    public setPropValue(key: string, val: any): any {
        this._props[key] = val;
    public get props() {
        return this._props;
    public clone(): Props {
        const res = new Props();
        for (const k in this._props)
            res._props[k] = this._props[k];
        return res;
/**
 * Nub utilisé dans une session
export class SessionNub {
    private _props: Props;
    constructor(private _nub: Nub, props: Props | {}) {
        if (this._nub == undefined)
            throw new Error(`NgNub.constructor() : argument invalide`);
        if (props instanceof Props)
            this._props = props.clone();
        else
            this._props = new Props(props);
    public get nub() {
        return this._nub;
    public get uid(): number {
        return this._nub.uid;
    public get properties() {
        return this._props;
7172737475
public hasProperties(p: Props | {}): boolean { return this._props.hasProperties(p); } }