/
aprogrammer
/
serilog
Обзор
Документация
Войти
/
aprogrammer
/
serilog
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
src/Serilog/Core/MessageTemplateFormatMethodAttribute.cs
38 строк
1 KB
Nicholas Blumhardt
Reuse `HashSet` instances, reduce LINQ usage, avoid reallocating `StructureValue._properties` (#2090)
25 июл 2024, 01:28
Не верифицирован
25 июл 2024, 01:28
5844a9f
Код
Авторство
О чём код?
namespace Serilog.Core; /// <summary> /// Indicates that the marked method logs data using a message template and (optional) arguments. /// The name of the parameter which contains the message template should be given in the constructor. /// </summary> /// <example> /// <code> /// [MessageTemplateFormatMethod("messageTemplate")] /// public void Information(string messageTemplate, params object[] propertyValues) /// { /// // Do something /// } /// /// public void Foo() /// { /// Information("Hello, {Name}!") // Warning: Nonexistent argument in message template. /// } /// </code> /// </example> [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method)] public sealed class MessageTemplateFormatMethodAttribute : Attribute { /// <summary> /// Initializes a new instance of the <see cref="MessageTemplateFormatMethodAttribute"/> class. /// </summary> /// <param name="messageTemplateParameterName">Name of the message template parameter.</param> public MessageTemplateFormatMethodAttribute(string messageTemplateParameterName) { MessageTemplateParameterName = messageTemplateParameterName; } /// <summary> /// Gets the name of the message template parameter. /// </summary> /// <value>The name of the message template parameter.</value> public string MessageTemplateParameterName { get; private set; } }