<commit_before>﻿using System;
using System.Net;
using System.Security;
using Microsoft.SharePoint.Client;

namespace SPO_Console_Starter
{
    class Program
    {
        #region private static variables
        
        private static ClientContext clientContext;
        private static ClientContext subclientContext;
        private static Site mysite;
        private static string mySiteRelativeUrl;
        private static SecureString passWord;
        private static string userName;
        private static string url;
        
        #endregion

        static void Main(string[] args)
        {
            ConnectToSite();
            ExecuteCustomCode();
            Console.Write("Press any key to continue...");
            Console.Read();
        }

        private static void ExecuteCustomCode()
        {
            Console.WriteLine("Hello, SPO!");
        }

        #region "helper functions"

        private static void ConnectToSite()
        {
            Console.WriteLine("Please enter the URL to the SharePoint Site");
            url = Console.ReadLine();

            Console.WriteLine("Please enter the username");
            userName = Console.ReadLine();

            Console.WriteLine("Please enter the Password");
            SecureString securePassword = getPassword();

            clientContext = new ClientContext(url);
            passWord = new SecureString();
            string charpassword = new NetworkCredential(string.Empty, securePassword).Password;
            foreach (char c in charpassword.ToCharArray()) passWord.AppendChar(c);
            clientContext.Credentials = new SharePointOnlineCredentials(userName, passWord);
            mysite = clientContext.Site;

            clientContext.Load(mysite);
            clientContext.ExecuteQuery();

            mySiteRelativeUrl = mysite.ServerRelativeUrl;

            clientContext.Load(mysite.RootWeb);
            clientContext.ExecuteQuery();

            Console.WriteLine("");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Successfully connected to site at " + mysite.Url);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Press any key to continue..");
            Console.ReadLine();
        }

        public static SecureString getPassword()
        {
            SecureString pwd = new SecureString();
            while (true)
            {
                ConsoleKeyInfo i = Console.ReadKey(true);
                if (i.Key == ConsoleKey.Enter)
                {
                    break;
                }
                else if (i.Key == ConsoleKey.Backspace)
                {
                    if (pwd.Length > 0)
                    {
                        pwd.RemoveAt(pwd.Length - 1);
                        Console.Write("\b \b");
                    }
                }
                else
                {
                    pwd.AppendChar(i.KeyChar);
                    Console.Write("*");
                }
            }
            return pwd;
        }

        #endregion
    }
}<commit_msg>Added UpdateSiteLogos method and tested functionality with success.<commit_after>﻿using System;
using System.Net;
using System.Security;
using Microsoft.SharePoint.Client;

namespace SPO_Console_Starter
{
    class Program
    {
        #region private static variables
        
        private static ClientContext clientContext;
        private static Site site;
        private static string siteRelativeUrl;
        private static SecureString password;
        private static string username;
        private static string url;
        
        #endregion

        static void Main(string[] args)
        {
            ConnectToSite();
            ExecuteCustomCode();
            Console.Write("Press any key to continue...");
            Console.Read();
        }

        private static void ExecuteCustomCode()
        {
            Console.WriteLine("Hello, SPO!");
            Console.WriteLine();

            //UpdateSiteLogos();
        }

        /// <summary>
        /// This method will set the site logo of each site to match the site logo of the top-level site in the site collection.
        /// Before running this, ensure that the site logo of the top-level site has been set to the desired logo.
        /// </summary>
        private static void UpdateSiteLogos()
        {
            string siteLogoUrl = "";
            Web rootWeb = site.RootWeb;
            siteLogoUrl = rootWeb.SiteLogoUrl;
            WebCollection subWebs = rootWeb.Webs;
            clientContext.Load(subWebs);
            clientContext.ExecuteQuery();
            foreach (Web subWeb in subWebs)
            {
                Console.WriteLine("Changing " + subWeb.Title + " site logo URL from " + subWeb.SiteLogoUrl + " to " + siteLogoUrl + ".");
                Console.WriteLine();
                subWeb.SiteLogoUrl = siteLogoUrl;
                subWeb.Update();
                clientContext.ExecuteQuery();
            }
        }

        #region "helper functions"

        private static void ConnectToSite()
        {
            Console.WriteLine("Please enter the URL to the SharePoint Site");
            url = Console.ReadLine();

            Console.WriteLine("Please enter the username");
            username = Console.ReadLine();

            Console.WriteLine("Please enter the password");
            SecureString securepassword = getpassword();

            clientContext = new ClientContext(url);
            password = new SecureString();
            string charpassword = new NetworkCredential(string.Empty, securepassword).Password;
            foreach (char c in charpassword.ToCharArray()) password.AppendChar(c);
            clientContext.Credentials = new SharePointOnlineCredentials(username, password);
            site = clientContext.Site;

            clientContext.Load(site);
            clientContext.ExecuteQuery();

            siteRelativeUrl = site.ServerRelativeUrl;

            clientContext.Load(site.RootWeb);
            clientContext.ExecuteQuery();

            Console.WriteLine("");
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Successfully connected to site at " + site.Url);
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Press any key to continue..");
            Console.ReadLine();
        }

        public static SecureString getpassword()
        {
            SecureString pwd = new SecureString();
            while (true)
            {
                ConsoleKeyInfo i = Console.ReadKey(true);
                if (i.Key == ConsoleKey.Enter)
                {
                    break;
                }
                else if (i.Key == ConsoleKey.Backspace)
                {
                    if (pwd.Length > 0)
                    {
                        pwd.RemoveAt(pwd.Length - 1);
                        Console.Write("\b \b");
                    }
                }
                else
                {
                    pwd.AppendChar(i.KeyChar);
                    Console.Write("*");
                }
            }
            return pwd;
        }

        #endregion
    }
}
{'fraction_non_alphanumeric': 0.08419314898885678, 'fraction_numerical': 0.0005502820195350117, 'mean_word_length': 1.557157931762223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1079712', 'n_tokens_mistral': 1716, 'n_tokens_neox': 1638, 'n_words': 430}