コード例 #1
0
ファイル: SlackClient.cs プロジェクト: Richard-West/Log4Slack
 /// <summary>
 /// Posts a payload to Slack.
 /// </summary>
 private void PostPayloadAsync(Payload payload)
 {
     var data = JsonSerializeObject(payload);
     PostPayloadAsync(data);
 }
コード例 #2
0
ファイル: SlackClient.cs プロジェクト: Richard-West/Log4Slack
        /// <summary>
        /// Builds a payload for Slack.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="username"></param>
        /// <param name="channel"></param>
        /// <param name="iconUrl"></param>
        /// <param name="iconEmoji"></param>
        /// <param name="attachments"></param>
        /// <returns></returns>
        private Payload BuildPayload(string text, string username, string channel, string iconUrl, string iconEmoji, List<Attachment> attachments = null)
        {
            username = string.IsNullOrEmpty(username) ? _username : username;
            channel = string.IsNullOrEmpty(channel) ? _channel : channel;
            iconUrl = string.IsNullOrEmpty(channel) ? _iconUrl : iconUrl;
            iconEmoji = string.IsNullOrEmpty(iconEmoji) ? _iconEmoji : iconEmoji;

            var payload = new Payload {
                Channel = channel,
                Username = username,
                IconUrl = iconUrl,
                IconEmoji = iconEmoji,
                Text = text,
                Attachments = attachments
            };

            return payload;
        }