<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SKM.V3.Models;
using SKM.V3.Internal;
using System.Security.Cryptography;
using Newtonsoft.Json.Linq;

namespace SKM.V3
{

    /// <summary>
    /// <para>
    /// This namespace should always be included since it contains the base classes and methods for Web API V3.
    /// </para>
    /// </summary>
    internal class NamespaceDoc
    {

    }


    /// <summary>
    /// The extension methods are not thought to be used through this class, but instead
    /// through the relevant objects that they affect. Please see the examples below.
    /// </summary>
    /// <example>
    /// <code language="csharp" title="Checking if a license key has feature 1 set to true and that it has not expired.">
    /// // assuming license is a LicenseKey object.
    /// if(license.HasFeature(1)
    ///           .HasNotExpired()
    ///           .IsValid())
    /// {
    ///     // do something
    /// }
    /// else
    /// {
    ///     // invalid license.
    /// }
    /// </code>
    /// </example>
    public static class ExtensionMethods
    {
        /// <summary>
        /// Saves the current <see cref="LicenseKey"/> object to file.
        /// </summary>
        /// <returns>Returns the original object if successful. Null otherwise.</returns>
        public static LicenseKey SaveToFile(this LicenseKey licenseKey)
        {
            string name = "licensekey.skm";
            return SaveToFile(licenseKey, name);
        }
        /// <summary>
        /// Saves the current <see cref="LicenseKey"/> object to file.
        /// </summary>
        /// <param name="file">The entire path including file name, i.e. c:\folder\file.txt</param>
        /// <returns>Returns the original object if successful. Null otherwise.</returns>
        public static LicenseKey SaveToFile(this LicenseKey licenseKey, string file)
        {
            System.IO.StreamWriter sw = null;
            bool state = false;
            try
            {
                sw = new System.IO.StreamWriter(file);
                sw.Write(licenseKey.SaveAsString());
                state = true;
            }
            catch
            {
                state = false;

            }
            finally<commit_msg>Update ExtensionMethods.cs<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SKM.V3.Models;
using SKM.V3.Internal;
using System.Security.Cryptography;
using Newtonsoft.Json.Linq;

namespace SKM.V3
{

    /// <summary>
    /// <para>
    /// This namespace should always be included since it contains the base classes and methods for Web API V3.
    /// </para>
    /// </summary>
    internal class NamespaceDoc
    {

    }


    /// <summary>
    /// The extension methods are not thought to be used through this class, but instead
    /// through the relevant objects that they affect. Please see the examples below.
    /// </summary>
    /// <example>
    /// <code language="csharp" title="Checking if a license key has feature 1 set to true and that it has not expired.">
    /// // assuming license is a LicenseKey object.
    /// if(license.HasFeature(1)
    ///           .HasNotExpired()
    ///           .IsValid())
    /// {
    ///     // do something
    /// }
    /// else
    /// {
    ///     // invalid license.
    /// }
    /// </code>
    /// </example>
    public static class ExtensionMethods
    {
        /// <summary>
        /// Saves the current <see cref="LicenseKey"/> object to file.
        /// </summary>
        /// <returns>Returns the original object if successful. Null otherwise.</returns>
        public static LicenseKey SaveToFile(this LicenseKey licenseKey)
        {
            string name = "licensekey.skm";
            return SaveToFile(licenseKey, name);
        }
        /// <summary>
        /// Saves the current <see cref="LicenseKey"/> object to file. 
        /// If you need a guarantee where the file will be saved, please specify an absolute path, e.g. 'C:\licensefile.skm'.
        /// If a relative path is specified, it will in most cases be saved in the current directory. The definition of what
        /// the current directory is will vary between execution environments.
        /// </summary>
        /// <param name="file">The entire path including file name, i.e. c:\folder\file.txt</param>
        /// <returns>Returns the original object if successful. Null otherwise.</returns>
        public static LicenseKey SaveToFile(this LicenseKey licenseKey, string file)
        {
            System.IO.StreamWriter sw = null;
            bool state = false;
            try
            {
                sw = new System.IO.StreamWriter(file);
                sw.Write(licenseKey.SaveAsString());
                state = true;
            }
            catch
            {
                state = false;

            }
            finally
{'fraction_non_alphanumeric': 0.11872237846524708, 'fraction_numerical': 0.0024106066693451184, 'mean_word_length': 1.7282191780821918, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, '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': '4617999', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1279, 'n_words': 434}