<commit_before>﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using Homie.Common.Interfaces;

namespace Homie.Common.WebService
{
    /// <summary>
    /// Factory class for web services.
    /// </summary>
    public class WebServiceFactory
    {
        private Binding binding;
        private string address;
        private int port;
        private string serviceEndPoint;
        public WebServiceFactory(Binding binding, string address, int port, string serviceEndPoint)
        {
            this.binding = binding;
            this.address = address;
            this.port = port;
            this.serviceEndPoint = serviceEndPoint;
        }

        public T Create<T>(UserNamePasswordClientCredential credentials = null)
        {
            // Determine the protocol of the web service
            var protocol = Protocol.Http; // default
            if (binding is BasicHttpsBinding)
            {
                protocol = Protocol.Https;
            }
            else if (binding is NetTcpBinding)
            {
                protocol = Protocol.NetTcp;
            }

            var endPointUrl = String.Format(Constants.WebServiceUrlTemplate, protocol, address, port, serviceEndPoint);

            if (typeof(T) == typeof(IMachineControlService))
            {
                endPointUrl = endPointUrl + Constants.MachineControlServiceEndPoint;
            }
            if (typeof(T) == typeof(IServiceLogProvider))
            {
                endPointUrl = endPointUrl + Constants.ServiceLogProviderEndPoint;
            }<commit_msg>Added automatic endpoint creation for IUserControlService in WebServiceFactory<commit_after>﻿using System;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Security;
using Homie.Common.Interfaces;

namespace Homie.Common.WebService
{
    /// <summary>
    /// Factory class for web services.
    /// </summary>
    public class WebServiceFactory
    {
        private Binding binding;
        private string address;
        private int port;
        private string serviceEndPoint;
        public WebServiceFactory(Binding binding, string address, int port, string serviceEndPoint)
        {
            this.binding = binding;
            this.address = address;
            this.port = port;
            this.serviceEndPoint = serviceEndPoint;
        }

        public T Create<T>(UserNamePasswordClientCredential credentials = null)
        {
            // Determine the protocol of the web service
            var protocol = Protocol.Http; // default
            if (binding is BasicHttpsBinding)
            {
                protocol = Protocol.Https;
            }
            else if (binding is NetTcpBinding)
            {
                protocol = Protocol.NetTcp;
            }

            var endPointUrl = String.Format(Constants.WebServiceUrlTemplate, protocol, address, port, serviceEndPoint);

            if (typeof(T) == typeof(IMachineControlService))
            {
                endPointUrl = endPointUrl + Constants.MachineControlServiceEndPoint;
            }
            if (typeof(T) == typeof(IUserControlService))
            {
                endPointUrl = endPointUrl + Constants.UserControlServiceEndPoint;
            }
            if (typeof(T) == typeof(IServiceLogProvider))
            {
                endPointUrl = endPointUrl + Constants.ServiceLogProviderEndPoint;
            }
{'fraction_non_alphanumeric': 0.07434944237918216, 'fraction_numerical': 0.0, 'mean_word_length': 1.964406779661017, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2391522', 'n_tokens_mistral': 849, 'n_tokens_neox': 828, 'n_words': 211}