<commit_before>﻿using System.IO;
using System.Net;
using System.Net.Http;
using Kudu.Client.Infrastructure;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;

namespace Kudu.Client.Deployment
{
    public class RemotePushDeploymentManager : KuduRemoteClientBase
    {
        public RemotePushDeploymentManager(string serviceUrl, ICredentials credentials = null, HttpMessageHandler handler = null)
            : base(serviceUrl, credentials, handler)
        {
        }

        public async Task<HttpResponseMessage> PushDeployFromStream(Stream zipFile, ZipDeployMetadata metadata)
        {
            using (var request = new HttpRequestMessage())
            {
                var parms = new List<string>();

                if (metadata.IsAsync)
                {
                    parms.Add("isAsync=true");
                }

                var map = new List<KeyValuePair<string, string>>
                {
                    new KeyValuePair<string, string>("author", metadata.Author),
                    new KeyValuePair<string, string>("authorEmail", metadata.AuthorEmail),
                    new KeyValuePair<string, string>("deployer", metadata.Deployer),
                    new KeyValuePair<string, string>("message", metadata.Message),
                };

                foreach (var item in map)
                {
                    if (item.Value != null)
                    {
                        parms.Add(
                            String.Format("{0}={1}", item.Key, item.Value));
                    }
                }

                if (parms.Any())
                {
                    request.RequestUri = new Uri(Client.BaseAddress + "?" + String.Join("&", parms));
                }

                request.Method = HttpMethod.Post;
                request.Content = new StreamContent(zipFile);
                return await Client.SendAsync(request);
            }
        }

        public async Task<HttpResponseMessage> PushDeployFromFile(string path, ZipDeployMetadata metadata)
        {
            using (var stream = File.OpenRead(path))
            {
                return await PushDeployFromStream(stream, metadata);
            }
        }
    }

    public class ZipDeployMetadata
    {
        public bool IsAsync;
        public string Author;
        public string AuthorEmail;
        public string Deployer;
        public string Message;
    }
}<commit_msg>Fixup for StyleCop error in previous commit<commit_after>﻿using System.IO;
using System.Net;
using System.Net.Http;
using Kudu.Client.Infrastructure;
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;

namespace Kudu.Client.Deployment
{
    public class RemotePushDeploymentManager : KuduRemoteClientBase
    {
        public RemotePushDeploymentManager(string serviceUrl, ICredentials credentials = null, HttpMessageHandler handler = null)
            : base(serviceUrl, credentials, handler)
        {
        }

        public async Task<HttpResponseMessage> PushDeployFromStream(Stream zipFile, ZipDeployMetadata metadata)
        {
            using (var request = new HttpRequestMessage())
            {
                var parms = new List<string>();

                if (metadata.IsAsync)
                {
                    parms.Add("isAsync=true");
                }

                var map = new List<KeyValuePair<string, string>>
                {
                    new KeyValuePair<string, string>("author", metadata.Author),
                    new KeyValuePair<string, string>("authorEmail", metadata.AuthorEmail),
                    new KeyValuePair<string, string>("deployer", metadata.Deployer),
                    new KeyValuePair<string, string>("message", metadata.Message),
                };

                foreach (var item in map)
                {
                    if (item.Value != null)
                    {
                        parms.Add(
                            String.Format("{0}={1}", item.Key, item.Value));
                    }
                }

                if (parms.Any())
                {
                    request.RequestUri = new Uri(Client.BaseAddress + "?" + String.Join("&", parms));
                }

                request.Method = HttpMethod.Post;
                request.Content = new StreamContent(zipFile);
                return await Client.SendAsync(request);
            }
        }

        public async Task<HttpResponseMessage> PushDeployFromFile(string path, ZipDeployMetadata metadata)
        {
            using (var stream = File.OpenRead(path))
            {
                return await PushDeployFromStream(stream, metadata);
            }
        }
    }

    public class ZipDeployMetadata
    {
        public bool IsAsync { get; set; }
        public string Author { get; set; }
        public string AuthorEmail { get; set; }
        public string Deployer { get; set; }
        public string Message { get; set; }
    }
}
{'fraction_non_alphanumeric': 0.08906962904185678, 'fraction_numerical': 0.0007934933544931561, 'mean_word_length': 1.6439433665443104, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3950518', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1202, 'n_words': 284}