mirror of
https://github.com/danieleteti/delphimvcframework.git
synced 2024-11-15 15:55:54 +01:00
167 lines
5.2 KiB
ObjectPascal
167 lines
5.2 KiB
ObjectPascal
// ***************************************************************************
|
|
//
|
|
// Delphi MVC Framework
|
|
//
|
|
// Copyright (c) 2010-2021 Daniele Teti and the DMVCFramework Team
|
|
//
|
|
// 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.
|
|
//
|
|
// ***************************************************************************
|
|
|
|
unit MVCFramework.Serializer.Intf;
|
|
|
|
{$I dmvcframework.inc}
|
|
|
|
interface
|
|
|
|
uses
|
|
System.Rtti,
|
|
System.TypInfo,
|
|
Data.DB,
|
|
MVCFramework.Commons,
|
|
MVCFramework.Serializer.Commons;
|
|
|
|
type
|
|
IMVCTypeSerializer = interface
|
|
['{806EC547-D1CB-4DA9-92D3-A8A7C0BD4009}']
|
|
procedure SerializeAttribute(
|
|
const AElementValue: TValue;
|
|
const APropertyName: string;
|
|
const ASerializerObject: TObject;
|
|
const AAttributes: TArray<TCustomAttribute>
|
|
);
|
|
|
|
procedure SerializeRoot(
|
|
const AObject: TObject;
|
|
out ASerializerObject: TObject;
|
|
const AAttributes: TArray<TCustomAttribute>;
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
);
|
|
|
|
procedure DeserializeAttribute(
|
|
var AElementValue: TValue;
|
|
const APropertyName: string;
|
|
const ASerializerObject: TObject;
|
|
const AAttributes: TArray<TCustomAttribute>
|
|
);
|
|
|
|
procedure DeserializeRoot(
|
|
const ASerializerObject: TObject;
|
|
const AObject: TObject;
|
|
const AAttributes: TArray<TCustomAttribute>
|
|
);
|
|
end;
|
|
|
|
IMVCSerializer = interface
|
|
['{1ECA942A-E3C4-45DD-9D23-C00363B5E334}']
|
|
procedure RegisterTypeSerializer(const ATypeInfo: PTypeInfo; AInstance: IMVCTypeSerializer);
|
|
|
|
function SerializeObject(
|
|
const AObject: TObject;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
): string; overload;
|
|
|
|
function SerializeObject(
|
|
const AObject: IInterface;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
): string; overload;
|
|
|
|
function SerializeCollection(
|
|
const AList: TObject;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
): string; overload;
|
|
|
|
function SerializeCollection(
|
|
const AList: IInterface;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
|
const ASerializationAction: TMVCSerializationAction = nil
|
|
): string; overload;
|
|
|
|
function SerializeDataSet(
|
|
const ADataSet: TDataSet;
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
|
const ANameCase: TMVCNameCase = ncAsIs;
|
|
const ASerializationAction: TMVCDatasetSerializationAction = nil
|
|
): string;
|
|
|
|
function SerializeDataSetRecord(
|
|
const ADataSet: TDataSet;
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
|
const ANameCase: TMVCNameCase = ncAsIs;
|
|
const ASerializationAction: TMVCDatasetSerializationAction = nil
|
|
): string;
|
|
|
|
procedure DeserializeObject(
|
|
const ASerializedObject: string;
|
|
const AObject: TObject;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
|
const ARootNode: String = ''
|
|
); overload;
|
|
|
|
procedure DeserializeObject(
|
|
const ASerializedObject: string;
|
|
const AObject: IInterface;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil
|
|
); overload;
|
|
|
|
procedure DeserializeCollection(
|
|
const ASerializedList: string;
|
|
const AList: TObject;
|
|
const AClazz: TClass;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil;
|
|
const ARootNode: String = ''
|
|
); overload;
|
|
|
|
procedure DeserializeCollection(
|
|
const ASerializedList: string;
|
|
const AList: IInterface;
|
|
const AClazz: TClass;
|
|
const AType: TMVCSerializationType = stDefault;
|
|
const AIgnoredAttributes: TMVCIgnoredList = nil
|
|
); overload;
|
|
|
|
procedure DeserializeDataSet(
|
|
const ASerializedDataSet: string;
|
|
const ADataSet: TDataSet;
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
|
const ANameCase: TMVCNameCase = ncAsIs
|
|
);
|
|
|
|
procedure DeserializeDataSetRecord(
|
|
const ASerializedDataSetRecord: string;
|
|
const ADataSet: TDataSet;
|
|
const AIgnoredFields: TMVCIgnoredList = [];
|
|
const ANameCase: TMVCNameCase = ncAsIs
|
|
);
|
|
end;
|
|
|
|
implementation
|
|
|
|
end.
|