<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;

namespace OpcMock
{
    public class ProjectFileWriter
    {
        private OpcMockProject opcMockProject;
        private string projectFolderPath;
        private string content;

        public ProjectFileWriter(OpcMockProject opcMockProject, string projectFolderPath)
        {
            this.projectFolderPath = projectFolderPath;
            this.opcMockProject = opcMockProject;
            this.content = string.Empty;
        }

        private string GetProjectFilePath()
        {
            return projectFolderPath + Path.DirectorySeparatorChar + opcMockProject.Name + OpcMockConstants.FileExtensionProject;
        }

        public void Save()
        {
            StringBuilder stringBuilder = new StringBuilder();

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.IndentChars = "    ";
            settings.OmitXmlDeclaration = true;

            XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, settings);

            xmlWriter.WriteStartDocument(true);

            xmlWriter.WriteStartElement("project");

            xmlWriter.WriteElementString("project_name", opcMockProject.Name);

            if (0 == opcMockProject.Protocols.Count)<commit_msg>Indentation changed for better testability<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;

namespace OpcMock
{
    public class ProjectFileWriter
    {
        private OpcMockProject opcMockProject;
        private string projectFolderPath;
        private string content;

        public ProjectFileWriter(OpcMockProject opcMockProject, string projectFolderPath)
        {
            this.projectFolderPath = projectFolderPath;
            this.opcMockProject = opcMockProject;
            this.content = string.Empty;
        }

        private string GetProjectFilePath()
        {
            return projectFolderPath + Path.DirectorySeparatorChar + opcMockProject.Name + OpcMockConstants.FileExtensionProject;
        }

        public void Save()
        {
            StringBuilder stringBuilder = new StringBuilder();
            string twoSpaces = "  ";

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;
            settings.IndentChars = twoSpaces;
            settings.OmitXmlDeclaration = true;

            XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, settings);

            xmlWriter.WriteStartDocument(true);

            xmlWriter.WriteStartElement("project");

            xmlWriter.WriteElementString("project_name", opcMockProject.Name);

            if (0 == opcMockProject.Protocols.Count)
{'fraction_non_alphanumeric': 0.06957756478523251, 'fraction_numerical': 0.0007099751508697196, 'mean_word_length': 2.5269086357947432, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '3801043', 'n_tokens_mistral': 695, 'n_tokens_neox': 669, 'n_words': 146}