2017-03-01 21:40:57 +01:00
|
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Delphi MVC Framework
|
|
|
|
|
//
|
2020-01-06 16:49:18 +01:00
|
|
|
|
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
|
2017-03-01 21:40:57 +01:00
|
|
|
|
//
|
|
|
|
|
// https://github.com/danieleteti/delphimvcframework
|
|
|
|
|
//
|
|
|
|
|
// Collaborators on this file: Ezequiel Juliano M<>ller (ezequieljuliano@gmail.com)
|
|
|
|
|
//
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
|
// limitations under the License.
|
|
|
|
|
//
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
2017-02-07 14:08:36 +01:00
|
|
|
|
unit MVCFramework.Serializer.Intf;
|
|
|
|
|
|
2017-03-23 18:51:25 +01:00
|
|
|
|
{$I dmvcframework.inc}
|
|
|
|
|
|
2017-02-07 14:08:36 +01:00
|
|
|
|
interface
|
|
|
|
|
|
|
|
|
|
uses
|
2017-03-01 21:40:57 +01:00
|
|
|
|
System.Rtti,
|
|
|
|
|
System.TypInfo,
|
2017-03-28 14:52:13 +02:00
|
|
|
|
Data.DB,
|
2020-04-20 17:56:17 +02:00
|
|
|
|
MVCFramework.Commons,
|
2017-03-28 14:52:13 +02:00
|
|
|
|
MVCFramework.Serializer.Commons;
|
2017-02-07 14:08:36 +01:00
|
|
|
|
|
|
|
|
|
type
|
2017-03-01 21:40:57 +01:00
|
|
|
|
IMVCTypeSerializer = interface
|
|
|
|
|
['{806EC547-D1CB-4DA9-92D3-A8A7C0BD4009}']
|
2018-10-30 13:53:01 +01:00
|
|
|
|
procedure SerializeAttribute(
|
2017-03-28 14:52:13 +02:00
|
|
|
|
const AElementValue: TValue;
|
2018-10-30 13:53:01 +01:00
|
|
|
|
const APropertyName: string;
|
|
|
|
|
const ASerializerObject: TObject;
|
|
|
|
|
const AAttributes: TArray<TCustomAttribute>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
procedure SerializeRoot(
|
|
|
|
|
const AObject: TObject;
|
|
|
|
|
out ASerializerObject: TObject;
|
2019-03-08 09:33:41 +01:00
|
|
|
|
const AAttributes: TArray<TCustomAttribute>;
|
|
|
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
2017-03-28 14:52:13 +02:00
|
|
|
|
);
|
|
|
|
|
|
2018-10-30 13:53:01 +01:00
|
|
|
|
procedure DeserializeAttribute(
|
2017-03-28 14:52:13 +02:00
|
|
|
|
var AElementValue: TValue;
|
2018-10-30 13:53:01 +01:00
|
|
|
|
const APropertyName: string;
|
|
|
|
|
const ASerializerObject: TObject;
|
|
|
|
|
const AAttributes: TArray<TCustomAttribute>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
procedure DeserializeRoot(
|
|
|
|
|
const ASerializerObject: TObject;
|
|
|
|
|
const AObject: TObject;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
const AAttributes: TArray<TCustomAttribute>
|
|
|
|
|
);
|
2017-02-09 11:24:18 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-02-09 19:33:59 +01:00
|
|
|
|
IMVCSerializer = interface
|
2017-02-07 14:08:36 +01:00
|
|
|
|
['{1ECA942A-E3C4-45DD-9D23-C00363B5E334}']
|
2017-03-01 21:40:57 +01:00
|
|
|
|
procedure RegisterTypeSerializer(const ATypeInfo: PTypeInfo; AInstance: IMVCTypeSerializer);
|
2017-02-07 14:08:36 +01:00
|
|
|
|
|
2017-03-28 14:52:13 +02:00
|
|
|
|
function SerializeObject(
|
|
|
|
|
const AObject: TObject;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
2017-04-29 23:56:56 +02:00
|
|
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
2019-09-18 01:14:54 +02:00
|
|
|
|
): string; overload;
|
|
|
|
|
|
|
|
|
|
function SerializeObject(
|
|
|
|
|
const AObject: IInterface;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
2019-09-18 01:14:54 +02:00
|
|
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
|
|
|
): string; overload;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
|
|
|
|
|
function SerializeCollection(
|
|
|
|
|
const AList: TObject;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
2019-03-08 09:33:41 +01:00
|
|
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
2019-09-18 01:14:54 +02:00
|
|
|
|
): string; overload;
|
|
|
|
|
|
|
|
|
|
function SerializeCollection(
|
|
|
|
|
const AList: IInterface;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
2019-09-18 01:14:54 +02:00
|
|
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
|
|
|
): string; overload;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
|
|
|
|
|
function SerializeDataSet(
|
|
|
|
|
const ADataSet: TDataSet;
|
|
|
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
2019-03-08 09:33:41 +01:00
|
|
|
|
const ANameCase: TMVCNameCase = ncAsIs;
|
2019-03-10 16:29:18 +01:00
|
|
|
|
const ASerializationAction: TMVCDatasetSerializationAction = nil
|
2017-03-28 14:52:13 +02:00
|
|
|
|
): string;
|
|
|
|
|
|
|
|
|
|
function SerializeDataSetRecord(
|
|
|
|
|
const ADataSet: TDataSet;
|
|
|
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
2019-03-08 09:33:41 +01:00
|
|
|
|
const ANameCase: TMVCNameCase = ncAsIs;
|
2019-03-10 16:29:18 +01:00
|
|
|
|
const ASerializationAction: TMVCDatasetSerializationAction = nil
|
2017-03-28 14:52:13 +02:00
|
|
|
|
): string;
|
|
|
|
|
|
|
|
|
|
procedure DeserializeObject(
|
|
|
|
|
const ASerializedObject: string;
|
|
|
|
|
const AObject: TObject;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil
|
2019-09-18 01:14:54 +02:00
|
|
|
|
); overload;
|
|
|
|
|
|
|
|
|
|
procedure DeserializeObject(
|
|
|
|
|
const ASerializedObject: string;
|
|
|
|
|
const AObject: IInterface;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil
|
2019-09-18 01:14:54 +02:00
|
|
|
|
); overload;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
|
|
|
|
|
procedure DeserializeCollection(
|
|
|
|
|
const ASerializedList: string;
|
|
|
|
|
const AList: TObject;
|
|
|
|
|
const AClazz: TClass;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil
|
2019-09-18 01:14:54 +02:00
|
|
|
|
); overload;
|
|
|
|
|
|
|
|
|
|
procedure DeserializeCollection(
|
|
|
|
|
const ASerializedList: string;
|
|
|
|
|
const AList: IInterface;
|
|
|
|
|
const AClazz: TClass;
|
|
|
|
|
const AType: TMVCSerializationType = stDefault;
|
2020-05-19 00:49:34 +02:00
|
|
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil
|
2019-09-18 01:14:54 +02:00
|
|
|
|
); overload;
|
2017-03-28 14:52:13 +02:00
|
|
|
|
|
|
|
|
|
procedure DeserializeDataSet(
|
|
|
|
|
const ASerializedDataSet: string;
|
|
|
|
|
const ADataSet: TDataSet;
|
2017-03-30 15:56:24 +02:00
|
|
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
|
|
|
|
const ANameCase: TMVCNameCase = ncAsIs
|
2017-03-28 14:52:13 +02:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
procedure DeserializeDataSetRecord(
|
|
|
|
|
const ASerializedDataSetRecord: string;
|
|
|
|
|
const ADataSet: TDataSet;
|
2017-03-30 15:56:24 +02:00
|
|
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
|
|
|
|
const ANameCase: TMVCNameCase = ncAsIs
|
2017-03-28 14:52:13 +02:00
|
|
|
|
);
|
2017-02-09 19:33:59 +01:00
|
|
|
|
end;
|
|
|
|
|
|
2017-02-07 14:08:36 +01:00
|
|
|
|
implementation
|
|
|
|
|
|
|
|
|
|
end.
|