#region License Information
/* HeuristicLab
* Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Collections.Generic;
using HeuristicLab.Persistence.Core;
namespace HeuristicLab.Persistence.Interfaces {
///
/// A composite serializer does not directly transform an object into its
/// serialized form. It merely decomposes into other objects, that can
/// later be used to recompose the same object.
///
public interface ICompositeSerializer {
///
/// Defines the Priorty of this composite serializer. Higher number means
/// higher prioriy. Negative numbers are fallback serializers that are
/// disabled by default.
///
/// All default generic composite serializers have priority 100. Specializations
/// have priority 200 so they will be tried first. Priorities are
/// only considered for default configurations.
///
int Priority { get; }
///
/// Determines for every type whether the composite serializer is applicable.
///
/// The type.
///
/// true if this instance can serialize the specified type; otherwise, false.
///
bool CanSerialize(Type type);
///
/// Give a reason if possibly why the given type cannot be serialized by this
/// ICompositeSerializer.
///
/// The type.
/// A string justifying why type cannot be serialized.
string JustifyRejection(Type type);
///
/// Generate MetaInfo necessary for instance creation. (e.g. dimensions
/// necessary for array creation.
///
/// An object.
/// An enumerable of s.
IEnumerable CreateMetaInfo(object obj);
///
/// Decompose an object into s, the tag name can be null,
/// the order in which elements are generated is guaranteed to be
/// the same as they will be supplied to the Populate method.
///
/// An object.
/// An enumerable of s.
IEnumerable Decompose(object obj);
///
/// Create an instance of the object using the provided meta information.
///
/// A type.
/// The meta information.
/// A fresh instance of the provided type.
object CreateInstance(Type type, IEnumerable metaInfo);
///
/// Fills an object with values from the previously generated s
/// in Decompose. The order in which the values are supplied is
/// the same as they where generated. names might be null.
///
/// An empty object instance.
/// The tags.
/// The type.
void Populate(object instance, IEnumerable tags, Type type);
}
}