// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
#pragma warning disable SA1649 // File name should match first type name
namespace MessagePack
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public class MessagePackObjectAttribute : Attribute
{
public bool KeyAsPropertyName { get; private set; }
public MessagePackObjectAttribute(bool keyAsPropertyName = false)
{
this.KeyAsPropertyName = keyAsPropertyName;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class KeyAttribute : Attribute
{
public int? IntKey { get; private set; }
public string StringKey { get; private set; }
public KeyAttribute(int x)
{
this.IntKey = x;
}
public KeyAttribute(string x)
{
this.StringKey = x;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
public class IgnoreMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
public class UnionAttribute : Attribute
{
///
/// Gets the distinguishing value that identifies a particular subtype.
///
public int Key { get; private set; }
///
/// Gets the derived or implementing type.
///
public Type SubType { get; private set; }
///
/// Initializes a new instance of the class.
///
/// The distinguishing value that identifies a particular subtype.
/// The derived or implementing type.
public UnionAttribute(int key, Type subType)
{
this.Key = key;
this.SubType = subType;
}
///
/// Initializes a new instance of the class.
///
/// The distinguishing value that identifies a particular subtype.
/// The full name (should be assembly qualified) of the derived or implementing type.
public UnionAttribute(int key, string subType)
{
this.Key = key;
this.SubType = Type.GetType(subType, throwOnError: true);
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = true)]
public class SerializationConstructorAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class MessagePackFormatterAttribute : Attribute
{
public Type FormatterType { get; private set; }
public object[] Arguments { get; private set; }
public MessagePackFormatterAttribute(Type formatterType)
{
this.FormatterType = formatterType;
}
public MessagePackFormatterAttribute(Type formatterType, params object[] arguments)
{
this.FormatterType = formatterType;
this.Arguments = arguments;
}
}
}