Add DataContract on Models in SVGLDLibs

This commit is contained in:
Guillaume Tauzin 2022-10-12 15:56:00 +02:00
parent 1cd25eba03
commit d1881ae8fa
27 changed files with 153 additions and 60 deletions

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class ActionContainerModel
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public enum AddingBehaviorEnumModel
{
[EnumMember]

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class AvailableContainerModel
{
/** type */

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class AvailableSymbolModel
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class CSSStyle
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class Category
{
[DataMember(EmitDefaultValue = false)]

View file

@ -3,8 +3,11 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class Configuration
{
public Configuration(AvailableContainerModel mainContainer)
{
MainContainer = mainContainer;

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class ContainerModel
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class ContainerProperties
{
/** id of the container */

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class EditorState
{

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class GetFeedbackRequest
{
[DataMember(EmitDefaultValue = false)]

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class GetFeedbackResponse
{
[DataMember(EmitDefaultValue = false)]

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class HistoryState
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class ImageModel
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class Margin
{
[DataMember(EmitDefaultValue = false)]

View file

@ -1,8 +1,13 @@
namespace SVGLDLibs.Models
using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class Message
{
[DataMember(EmitDefaultValue = false)]
public string text { get; set; }
[DataMember(EmitDefaultValue = false)]
public MessageType type { get; set; }
}
}

View file

@ -1,10 +1,17 @@
using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public enum MessageType
{
[EnumMember]
Normal,
[EnumMember]
Success,
[EnumMember]
Warning,
[EnumMember]
Error
}
}

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public enum Orientation
{
[EnumMember]

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class Pattern
{

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class PointModel
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public enum Position
{
[EnumMember]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public enum PositionReferenceEnumModel
{
[EnumMember]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class SetContainerListRequest
{
[DataMember(EmitDefaultValue = false)]

View file

@ -3,6 +3,7 @@ using System.Runtime.Serialization;
namespace SVGLDLibs.Models
{
[DataContract]
public class SetContainerListResponse
{
[DataMember(EmitDefaultValue = false)]

View file

@ -2,6 +2,7 @@
namespace SVGLDLibs.Models
{
[DataContract]
public class SymbolModel : AvailableSymbolModel
{
[DataMember(EmitDefaultValue = false)]

112
public/svgld.d.ts vendored
View file

@ -9,7 +9,8 @@ declare namespace SVGLD {
export enum AddMethod {
Append = 0,
Insert = 1,
Replace = 2
Replace = 2,
ReplaceParent = 3
}
export enum MessageType {
@ -19,6 +20,30 @@ export enum MessageType {
Error = 3
}
export enum Orientation {
Horizontal = 0,
Vertical = 1
}
export enum Position {
Left = 0,
Down = 1,
Up = 2,
Right = 3
}
export enum PositionReference {
TopLeft = 0,
TopCenter = 1,
TopRight = 2,
CenterLeft = 3,
CenterCenter = 4,
CenterRight = 5,
BottomLeft = 6,
BottomCenter = 7,
BottomRight = 8
}
/**
* Describe the type of the property.
* Used for the assignation in the OnPropertyChange function
@ -39,12 +64,6 @@ export enum PropertyType {
Margin = 2
}
export enum XPositionReference {
Left = 0,
Center = 1,
Right = 2
}
export interface IAction {
@ -61,6 +80,8 @@ export interface IAction {
/** Model of available container used in application configuration */
export interface IAvailableContainer {
/** type */
@ -69,6 +90,8 @@ export interface IAvailableContainer {
DisplayedText?: string;
/** category */
Category?: string;
/** orientation */
Orientation?: Orientation;
/** horizontal offset */
X?: number;
/** vertical offset */
@ -79,14 +102,20 @@ export interface IAvailableContainer {
Height?: number;
/**
* Minimum width (min=1)
* Allows the container to set isRigidBody to false when it gets squeezed
* by an anchor
*/
MinWidth?: number;
/**
* Maximum width
*/
MaxWidth?: number;
/**
* Minimum height (min=1)
*/
MinHeight?: number;
/**
* Maximum height
*/
MaxHeight?: number;
/** margin */
Margin?: IMargin;
/** true if anchor, false otherwise */
@ -96,7 +125,7 @@ export interface IAvailableContainer {
/** Method used on container add */
AddMethod?: AddMethod;
/** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */
XPositionReference?: XPositionReference;
PositionReference?: PositionReference;
/**
* (optional)
* Replace a <rect> by a customized "SVG". It is not really an svg but it at least allows
@ -135,19 +164,21 @@ export interface IAvailableContainer {
* DefaultChildType will be disabled for this container and the children
*/
Pattern?: string;
/** Hide the children in the treeview */
HideChildrenInTreeview?: boolean;
/** if true, show the dimension of the container */
ShowSelfDimensions?: boolean;
ShowSelfDimensions?: Position[];
/** if true show the overall dimensions of its children */
ShowChildrenDimensions?: boolean;
ShowChildrenDimensions?: Position[];
/**
* if true, allows a parent dimension borrower to uses its x coordinate for as a reference point for a dimension
*/
MarkPositionToDimensionBorrower?: boolean;
MarkPosition?: Orientation[];
/**
* if true, show a dimension from the edge of the container to end
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
* and insert dimensions marks at lift up children (see MarkPosition)
*/
IsDimensionBorrower?: boolean;
ShowDimensionWithMarks?: Position[];
/**
* if true, hide the entry in the sidebar (default: false)
*/
@ -187,7 +218,7 @@ export interface IAvailableSymbol {
Image: IImage;
Width?: number;
Height?: number;
XPositionReference?: XPositionReference;
PositionReference?: PositionReference;
}
export interface ICategory {
@ -210,7 +241,7 @@ export interface IConfiguration {
export interface IContainerModel {
children: IContainerModel[];
children: string[];
parent: IContainerModel | null;
properties: IContainerProperties;
userData: Record<string, string | number>;
@ -220,16 +251,18 @@ export interface IContainerModel {
* Do not add methods since they will be lost during serialization
*/
export class ContainerModel implements IContainerModel {
children: IContainerModel[];
children: string[];
parent: IContainerModel | null;
properties: IContainerProperties;
userData: Record<string, string | number>;
constructor(parent: IContainerModel | null, properties: IContainerProperties, children?: IContainerModel[], userData?: {});
constructor(parent: IContainerModel | null, properties: IContainerProperties, children?: string[], userData?: {});
}
/**
* Properties of a container
*/
@ -244,46 +277,56 @@ export interface IContainerProperties {
linkedSymbolId: string;
/** Text displayed in the container */
displayedText: string;
/** orientation */
orientation: Orientation;
/** horizontal offset */
x: number;
/** vertical offset */
y: number;
/** margin */
margin: IMargin;
/** width */
width: number;
/** height */
height: number;
/**
* Minimum width (min=1)
* Allows the container to set isRigidBody to false when it gets squeezed
* by an anchor
*/
minWidth: number;
/**
* Maximum width
*/
maxWidth: number;
/** width */
width: number;
/** height */
height: number;
/**
* Minimum height (min=1)
*/
minHeight: number;
/**
* Maximum height
*/
maxHeight: number;
/** true if anchor, false otherwise */
isAnchor: boolean;
/** true if flex, false otherwise */
isFlex: boolean;
/** Horizontal alignment, also determines the visual location of x {Left = 0, Center, Right } */
xPositionReference: XPositionReference;
positionReference: PositionReference;
/** Hide the children in the treeview */
hideChildrenInTreeview: boolean;
/** if true, show the dimension of the container */
showSelfDimensions: boolean;
showSelfDimensions: Position[];
/** if true show the overall dimensions of its children */
showChildrenDimensions: boolean;
showChildrenDimensions: Position[];
/**
* if true, allows a parent dimension borrower to borrow its x coordinate
* as a reference point for a dimension
*/
markPositionToDimensionBorrower: boolean;
markPosition: Orientation[];
/**
* if true, show a dimension from the edge of the container to end
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
*/
isDimensionBorrower: boolean;
showDimensionWithMarks: Position[];
/**
* Warnings of a container
*/
@ -340,7 +383,8 @@ export interface IHistoryState {
/** Last editor action */
lastAction: string;
/** Reference to the main container */
mainContainer: IContainerModel;
mainContainer: string;
containers: Map<string, IContainerModel>;
/** Id of the selected container */
selectedContainerId: string;
/** Counter of type of container. Used for ids. */
@ -371,6 +415,7 @@ export interface IImage {
export interface IInputGroup {
key: string;
text: React.ReactNode;
value: string;
}
@ -420,9 +465,10 @@ export interface IPoint {
export interface ISetContainerListRequest {
/** Name of the action declared in the API */
Action: string;
Action: IAction;
/** Selected container */
Container: IContainerModel;
/** The previous sibling container */
@ -434,8 +480,10 @@ export interface ISetContainerListRequest {
}
export interface ISetContainerListResponse {
Containers: IAvailableContainer[];
AddingBehavior?: AddMethod;
}
/**

62
src/dts/svgld.d.ts vendored
View file

@ -9,7 +9,8 @@ declare namespace SVGLD {
export enum AddMethod {
Append = 0,
Insert = 1,
Replace = 2
Replace = 2,
ReplaceParent = 3
}
export enum MessageType {
@ -19,6 +20,18 @@ export enum MessageType {
Error = 3
}
export enum Orientation {
Horizontal = 0,
Vertical = 1
}
export enum Position {
Left = 0,
Down = 1,
Up = 2,
Right = 3
}
export enum PositionReference {
TopLeft = 0,
TopCenter = 1,
@ -51,12 +64,6 @@ export enum PropertyType {
Margin = 2
}
export enum XPositionReference {
Left = 0,
Center = 1,
Right = 2
}
export interface IAction {
@ -74,6 +81,7 @@ export interface IAction {
/** Model of available container used in application configuration */
export interface IAvailableContainer {
/** type */
@ -159,18 +167,18 @@ export interface IAvailableContainer {
/** Hide the children in the treeview */
HideChildrenInTreeview?: boolean;
/** if true, show the dimension of the container */
ShowSelfDimensions?: boolean;
ShowSelfDimensions?: Position[];
/** if true show the overall dimensions of its children */
ShowChildrenDimensions?: boolean;
ShowChildrenDimensions?: Position[];
/**
* if true, allows a parent dimension borrower to uses its x coordinate for as a reference point for a dimension
*/
MarkPositionToDimensionBorrower?: boolean;
MarkPosition?: Orientation[];
/**
* if true, show a dimension from the edge of the container to end
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
* and insert dimensions marks at lift up children (see MarkPosition)
*/
IsDimensionBorrower?: boolean;
ShowDimensionWithMarks?: Position[];
/**
* if true, hide the entry in the sidebar (default: false)
*/
@ -210,7 +218,7 @@ export interface IAvailableSymbol {
Image: IImage;
Width?: number;
Height?: number;
XPositionReference?: PositionReference;
PositionReference?: PositionReference;
}
export interface ICategory {
@ -233,7 +241,7 @@ export interface IConfiguration {
export interface IContainerModel {
children: IContainerModel[];
children: string[];
parent: IContainerModel | null;
properties: IContainerProperties;
userData: Record<string, string | number>;
@ -243,17 +251,18 @@ export interface IContainerModel {
* Do not add methods since they will be lost during serialization
*/
export class ContainerModel implements IContainerModel {
children: IContainerModel[];
children: string[];
parent: IContainerModel | null;
properties: IContainerProperties;
userData: Record<string, string | number>;
constructor(parent: IContainerModel | null, properties: IContainerProperties, children?: IContainerModel[], userData?: {});
constructor(parent: IContainerModel | null, properties: IContainerProperties, children?: string[], userData?: {});
}
/**
* Properties of a container
*/
@ -305,19 +314,19 @@ export interface IContainerProperties {
/** Hide the children in the treeview */
hideChildrenInTreeview: boolean;
/** if true, show the dimension of the container */
showSelfDimensions: boolean;
showSelfDimensions: Position[];
/** if true show the overall dimensions of its children */
showChildrenDimensions: boolean;
showChildrenDimensions: Position[];
/**
* if true, allows a parent dimension borrower to borrow its x coordinate
* as a reference point for a dimension
*/
markPositionToDimensionBorrower: boolean;
markPosition: Orientation[];
/**
* if true, show a dimension from the edge of the container to end
* and insert dimensions marks at lift up children (see liftDimensionToBorrower)
*/
isDimensionBorrower: boolean;
showDimensionWithMarks: Position[];
/**
* Warnings of a container
*/
@ -374,7 +383,8 @@ export interface IHistoryState {
/** Last editor action */
lastAction: string;
/** Reference to the main container */
mainContainer: IContainerModel;
mainContainer: string;
containers: Map<string, IContainerModel>;
/** Id of the selected container */
selectedContainerId: string;
/** Counter of type of container. Used for ids. */
@ -455,9 +465,10 @@ export interface IPoint {
export interface ISetContainerListRequest {
/** Name of the action declared in the API */
Action: string;
Action: IAction;
/** Selected container */
Container: IContainerModel;
/** The previous sibling container */
@ -469,8 +480,10 @@ export interface ISetContainerListRequest {
}
export interface ISetContainerListResponse {
Containers: IAvailableContainer[];
AddingBehavior?: AddMethod;
}
/**
@ -501,9 +514,4 @@ export interface ISymbolModel {
linkedContainers: Set<string>;
}
export enum Orientation {
Horizontal = 0,
Vertical = 1
}
}