<commit_before>﻿using murrayju.ProcessExtensions;
using System.Net.NetworkInformation;
using Tulpep.Network.NetworkStateService;
using Tulpep.NetworkAutoSwitch.NetworkStateLibrary;

namespace Tulpep.NetworkAutoSwitch.ProxyService
{
    public class ManageProxyState
    {
        public static void AnalyzeNow(Priority priority)
        {
         
            NetworkState networkState = NetworkStateService.RefreshNetworkState(priority);
            Logging.WriteMessage("Wireless: {0} | Wired: {1}" , networkState.WirelessStatus, networkState.WiredStatus);

            if(networkState.WiredStatus == OperationalStatus.Up && networkState.WirelessStatus == OperationalStatus.Down)
            {
                    ModifyProxyState(priority == Priority.Wired);
            }
            else if (networkState.WirelessStatus == OperationalStatus.Up && networkState.WiredStatus == OperationalStatus.Down)
            {
                    ModifyProxyState(priority == Priority.Wireless);
            }
            else if (networkState.WirelessStatus == OperationalStatus.Up && networkState.WiredStatus == OperationalStatus.Up)
            {
                    ModifyProxyState(true);
            }
            else if (networkState.WirelessStatus == OperationalStatus.Down && networkState.WiredStatus == OperationalStatus.Down)
            {
                    ModifyProxyState(false);
            }
        }


        public static void ModifyProxyState(bool enableProxy)
        {
          // if(enableProxy) ProcessExtensions.StartProcessAsCurrentUser("calc.exe");
            //else ProcessExtensions.StartProcessAsCurrentUser("calc.exe");
            Logging.WriteMessage((enableProxy ? "Enable" : "Disable") + " Proxy Server");<commit_msg>Different logic if Interactive<commit_after>﻿using murrayju.ProcessExtensions;
using System;
using System.Diagnostics;
using System.Net.NetworkInformation;
using Tulpep.Network.NetworkStateService;
using Tulpep.NetworkAutoSwitch.NetworkStateLibrary;

namespace Tulpep.NetworkAutoSwitch.ProxyService
{
    public class ManageProxyState
    {
        public static void AnalyzeNow(Priority priority)
        {
         
            NetworkState networkState = NetworkStateService.RefreshNetworkState(priority);
            Logging.WriteMessage("Wireless: {0} | Wired: {1}" , networkState.WirelessStatus, networkState.WiredStatus);

            if(networkState.WiredStatus == OperationalStatus.Up && networkState.WirelessStatus == OperationalStatus.Down)
            {
                    ModifyProxyState(priority == Priority.Wired);
            }
            else if (networkState.WirelessStatus == OperationalStatus.Up && networkState.WiredStatus == OperationalStatus.Down)
            {
                    ModifyProxyState(priority == Priority.Wireless);
            }
            else if (networkState.WirelessStatus == OperationalStatus.Up && networkState.WiredStatus == OperationalStatus.Up)
            {
                    ModifyProxyState(true);
            }
            else if (networkState.WirelessStatus == OperationalStatus.Down && networkState.WiredStatus == OperationalStatus.Down)
            {
                    ModifyProxyState(false);
            }
        }


        public static void ModifyProxyState(bool enableProxy)
        {
            Logging.WriteMessage((enableProxy ? "Enable" : "Disable") + " Proxy Server");
            if (Environment.UserInteractive)
            {
                Process.Start("calc");
            }
            else
            {
                ProcessExtensions.StartProcessAsCurrentUser("calc.exe");
            }
{'fraction_non_alphanumeric': 0.08744827586206896, 'fraction_numerical': 0.001103448275862069, 'mean_word_length': 2.4046948356807514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2400520', 'n_tokens_mistral': 917, 'n_tokens_neox': 870, 'n_words': 145}