Home Manual Reference Source Repository

docs/stack/controls/StackControlSerializer.js

import { ConfiguredRenderable } from '../../dom';
import { Inject, Type } from '../../di';
import { GenericSerializer, SerializerContainer, Serializer, Serialized } from '../../serialization';
import { XYDirection, RenderableConstructorArg, ConfigureableType } from '../../common';
import { StackControlPosition, StackControl } from './StackControl';

export interface SerializedStackControl extends Serialized {
  position: StackControlPosition;
}

export class StackControlSerializer<R extends StackControl> extends GenericSerializer<R> implements Serializer<R, SerializedStackControl> {
  serialize(node: R): SerializedStackControl {
    return {
      name: this._name,
      position: node.position
    };
  }

  deserialize(node: SerializedStackControl): RenderableConstructorArg<R> {
    return this._Class.configure ? this._Class.configure(node) : this._Class;
  }
}