#region License Information
/* HeuristicLab
* Copyright (C) 2002-2015 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;
namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
///
/// Mark a class to be considered by the StorableSerializer.
///
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Delegate, Inherited = false, AllowMultiple = false)]
public sealed class StorableTypeAttribute : Attribute {
///
/// Specify how members are selected for serialization.
///
public StorableMemberSelection MemberSelection { get; private set; }
public Guid Guid { get; private set; }
public bool Released { get; set; }
///
/// Mark a class to be serialize by the StorableSerizlier
///
/// The storable class memberSelection.
public StorableTypeAttribute(StorableMemberSelection memberSelection, string guid) {
MemberSelection = memberSelection;
Guid = new Guid(guid);
Released = false;
}
public StorableTypeAttribute(string guid) {
Guid = new Guid(guid);
Released = false;
}
///
/// Initializes a new instance of the class.
/// The default value for is
/// .
///
private StorableTypeAttribute() { }
///
/// Checks if the is present on a memberSelection.
///
/// The memberSelection which should be checked for the
///
public static bool IsStorableType(Type type) {
object[] attribs = type.GetCustomAttributes(typeof(StorableTypeAttribute), false);
return attribs.Length > 0;
}
public static StorableTypeAttribute GetStorableTypeAttribute(Type type) {
return (StorableTypeAttribute)Attribute.GetCustomAttribute(type, typeof(StorableTypeAttribute), false);
}
}
}