Search Results for

    Show / Hide Table of Contents

    Class SerializedNameAttribute

    Specifies a name for the serialized field or property in an object being wrapped by Generated<T>(Config, Boolean) that is different from the member name itself.

    Inheritance
    System.Object
    System.Attribute
    SerializedNameAttribute
    Implements
    System.Runtime.InteropServices._Attribute
    Inherited Members
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
    System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type)
    System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.Module)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.Module, System.Type)
    System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
    System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
    System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
    System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
    System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type, System.Boolean)
    System.Attribute.Equals(System.Object)
    System.Attribute.GetHashCode()
    System.Attribute.Match(System.Object)
    System.Attribute.IsDefaultAttribute()
    System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfoCount(System.UInt32)
    System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfo(System.UInt32, System.UInt32, System.IntPtr)
    System.Attribute.System.Runtime.InteropServices._Attribute.GetIDsOfNames(System.Guid, System.IntPtr, System.UInt32, System.UInt32, System.IntPtr)
    System.Attribute.System.Runtime.InteropServices._Attribute.Invoke(System.UInt32, System.Guid, System.UInt32, System.Int16, System.IntPtr, System.IntPtr, System.IntPtr, System.IntPtr)
    System.Attribute.TypeId
    System.Object.ToString()
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: IPA.Config.Stores.Attributes
    Assembly: IPA.Loader.dll
    Syntax
    [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
    public sealed class SerializedNameAttribute : Attribute, _Attribute
    Examples

    When serializing the following object, we might get the JSON that follows.

    public class PluginConfig
    {
        public virtual bool BooleanField { get; set; } = true;
    }
    {
        "BooleanField": true
    }

    However, if we were to add a SerializedNameAttribute to that field, we would get the following.

    public class PluginConfig
    {
        [SerializedName("bool")]
        public virtual bool BooleanField { get; set; } = true;
    }
    {
        "bool": true
    }

    Constructors

    | Improve this Doc View Source

    SerializedNameAttribute(String)

    Creates a new SerializedNameAttribute with the given Name.

    Declaration
    public SerializedNameAttribute(string name)
    Parameters
    Type Name Description
    System.String name

    the value to assign to Name

    Properties

    | Improve this Doc View Source

    Name

    Gets the name to replace the member name with.

    Declaration
    public string Name { get; }
    Property Value
    Type Description
    System.String

    Implements

    System.Runtime.InteropServices._Attribute

    Extension Methods

    ReflectionUtil.SetField<T, U>(T, String, U)
    ReflectionUtil.GetField<U, T>(T, String)
    ReflectionUtil.SetProperty<T, U>(T, String, U)
    ReflectionUtil.GetProperty<U, T>(T, String)
    ReflectionUtil.InvokeMethod<U, T>(T, String, Object[])
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX