using System.Collections.Generic;
namespace Unity.Cloud.UserReporting
{
///
/// Provides extensions for working with attachments.
///
public static class AttachmentExtensions
{
#region Static Methods
///
/// Adds a JSON attachment.
///
/// The extended instance.
/// The name of the attachment.
/// The file name.
/// The contents.
public static void AddJson(this List instance, string name, string fileName, string contents)
{
if (instance != null)
{
instance.Add(new UserReportAttachment(name, fileName, "application/json", System.Text.Encoding.UTF8.GetBytes(contents)));
}
}
///
/// Adds a text attachment.
///
/// The extended instance.
/// The name of the attachment.
/// The file name.
/// The contents.
public static void AddText(this List instance, string name, string fileName, string contents)
{
if (instance != null)
{
instance.Add(new UserReportAttachment(name, fileName, "text/plain", System.Text.Encoding.UTF8.GetBytes(contents)));
}
}
#endregion
}
}