MapPropertyAttribute
Specifies options for a property mapping.
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace Riok.Mapperly.Abstractions
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public sealed class MapPropertyAttribute : Attribute
{
private const string PropertyAccessSeparatorStr = ".";
private const char PropertyAccessSeparator = '.';
public IReadOnlyCollection<string> Source { get; }
public string SourceFullName => string.Join(".", Source);
public IReadOnlyCollection<string> Target { get; }
[System.Runtime.CompilerServices.Nullable(2)]
[field: System.Runtime.CompilerServices.Nullable(2)]
public string StringFormat {
[System.Runtime.CompilerServices.NullableContext(2)]
get;
[System.Runtime.CompilerServices.NullableContext(2)]
set;
}
[System.Runtime.CompilerServices.Nullable(2)]
[field: System.Runtime.CompilerServices.Nullable(2)]
public string FormatProvider {
[System.Runtime.CompilerServices.NullableContext(2)]
get;
[System.Runtime.CompilerServices.NullableContext(2)]
set;
}
public string TargetFullName => string.Join(".", Target);
public MapPropertyAttribute(string source, string target)
: this(source.Split(new char[1] {
'.'
}), target.Split(new char[1] {
'.'
}))
{
}
public MapPropertyAttribute(string[] source, string[] target)
{
Source = (IReadOnlyCollection<string>)source;
Target = (IReadOnlyCollection<string>)target;
}
}
}