/// <summary> /// Formats and adds the parameter to the <see cref="PutItemRequest"/>. /// </summary> /// <param name="request">The request.</param> /// <param name="loggingEvent">The logging event.</param> /// <returns>Chainable reference to the original request.</returns> public virtual PutItemRequest AddFormatParameter(PutItemRequest request, LoggingEvent loggingEvent) { request.CheckNull("request"); loggingEvent.CheckNull("loggingEvent"); object formattedValue = Layout.Format(loggingEvent); return AddToItemsIfNotNullOrEmpty(request, formattedValue); }
/// <summary> /// Add the specifed string item to the <c>Request.Items</c> collection if it is not empty. /// </summary> /// <param name="request">The <see cref="PutItemRequest"/>.</param> /// <param name="logItem">The log item.</param> /// <returns>Chainable reference to the original request.</returns> protected virtual PutItemRequest AddToItemsIfNotNullOrEmpty(PutItemRequest request, object logItem) { request.CheckNull("request"); if (null != logItem && !string.IsNullOrEmpty(logItem.ToString())) { DynamoDbAttributeBuilder builder = new DynamoDbAttributeBuilder(); switch (Type) { case ParameterType.B: request.Item.Add(Name, builder.BuildAttributeForTypeBinary(logItem)); break; case ParameterType.N: request.Item.Add(Name, builder.BuildAttributeForTypeNumeric(logItem)); break; default: request.Item.Add(Name, builder.BuildAttributeForTypeString(logItem)); break; } } return request; }