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 namespace SVGLDLibs.Models
{ {
[DataContract]
public class ActionContainerModel public class ActionContainerModel
{ {
[DataMember(EmitDefaultValue = false)] [DataMember(EmitDefaultValue = false)]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

112
public/svgld.d.ts vendored
View file

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

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

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