1.0-northcote/cs/Sharpen/DataFormatters/JsonDataFormatter.cs
/// <summary>
/// Exports the counterpoise correction calculation data in JavaScript object notation format (JSON)
/// </summary>
/// <param name="encounter">Instance of class implementing <see cref="IEncounter"/> containing the calculation data.</param>
/// <param name="stream">Stream to write JSON formatted data into.</param>
Exports the counterpoise correction calculation data in JavaScript object notation format (JSON)
Exports the counterpoise correction calculation data in JavaScript object notation format ( JSON )
public void ExportData(IEncounter encounter, Stream stream)
        {
            StreamWriter json = new StreamWriter(stream);
            json.Write("{");
            json.Write("\n\t\"Description\" : \"" + encounter.Description + "\",");
            json.Write("\n\t\"Basis\" : [");
            json.Write("\n\t\t{ \"Type\" : \"Dimer\", \"Dimer\" : \"");
            if (encounter.EnergyCount >= 1)
            {
                json.Write(encounter.Dimer.ToString());
            }
            json.Write("\", \"MonomerA\" : \"");
            if (encounter.EnergyCount >= 2)
            {
                json.Write(encounter.MonomerADimerBasis.ToString());
            }
            json.Write("\", \"MonomerB\" : \"");
            if (encounter.EnergyCount >= 3)
            {
                json.Write(encounter.MonomerBDimerBasis.ToString());
            }
            json.Write("\" },");
            json.Write("\n\t\t{ \"Type\" : \"Monomer\", \"MonomerA\" : \"");
            if (encounter.EnergyCount >= 4)
            {
                json.Write(encounter.MonomerAMonomerBasis.ToString());
            }
            json.Write("\", \"MonomerB\" : \"");
            if (encounter.EnergyCount == 5)
            {
                json.Write(encounter.MonomerBMonomerBasis.ToString());
            }
            json.Write("\" }");
            json.Write("\n\t],");
            json.Write("\n\t\"InteractionEnergy\" : {");
            json.Write("\n\t\t\"Hartree\" : \"");
            if (encounter.EnergyCount >= 3)
            {
                json.Write(encounter.InteractionEnergyHartrees.ToString());
            }
            json.Write("\",");
            json.Write("\n\t\t\"Kjmol\" : \"");
            if (encounter.EnergyCount >= 3)
            {
                json.Write(encounter.InteractionEnergyKjmol.ToString());
            }
            json.Write("\"");
            json.Write("\n\t},");
            json.Write("\n\t\"BindingConstant\" : \"");
            if (encounter.EnergyCount >= 3)
            {
                json.Write(encounter.BindingConstant.ToString());
            }
            json.Write("\"");
            json.Write("\n}");
            json.Close();
        }
public void ExportData ( IEncounter encounter , Stream stream ) { StreamWriter json = new StreamWriter ( stream ) ; json . Write ( " " ) ; json . Write ( " \n \t \" \" \" " + encounter . Description + " \" " ) ; json . Write ( " \n \t \" \" " ) ; json . Write ( " \n \t \t \" \" \" \" \" \" \" " ) ; if ( encounter . EnergyCount >= 1 ) { json . Write ( encounter . Dimer . ToString ( ) ) ; } json . Write ( " \" \" \" \" " ) ; if ( encounter . EnergyCount >= 2 ) { json . Write ( encounter . MonomerADimerBasis . ToString ( ) ) ; } json . Write ( " \" \" \" \" " ) ; if ( encounter . EnergyCount >= 3 ) { json . Write ( encounter . MonomerBDimerBasis . ToString ( ) ) ; } json . Write ( " \" " ) ; json . Write ( " \n \t \t \" \" \" \" \" \" \" " ) ; if ( encounter . EnergyCount >= 4 ) { json . Write ( encounter . MonomerAMonomerBasis . ToString ( ) ) ; } json . Write ( " \" \" \" \" " ) ; if ( encounter . EnergyCount == 5 ) { json . Write ( encounter . MonomerBMonomerBasis . ToString ( ) ) ; } json . Write ( " \" " ) ; json . Write ( " \n \t " ) ; json . Write ( " \n \t \" \" " ) ; json . Write ( " \n \t \t \" \" \" " ) ; if ( encounter . EnergyCount >= 3 ) { json . Write ( encounter . InteractionEnergyHartrees . ToString ( ) ) ; } json . Write ( " \" " ) ; json . Write ( " \n \t \t \" \" \" " ) ; if ( encounter . EnergyCount >= 3 ) { json . Write ( encounter . InteractionEnergyKjmol . ToString ( ) ) ; } json . Write ( " \" " ) ; json . Write ( " \n \t " ) ; json . Write ( " \n \t \" \" \" " ) ; if ( encounter . EnergyCount >= 3 ) { json . Write ( encounter . BindingConstant . ToString ( ) ) ; } json . Write ( " \" " ) ; json . Write ( " \n " ) ; json . Close ( ) ; }
Exports the counterpoise correction calculation data in JavaScript object notation format (JSON)
Exports the counterpoise correction calculation data in JavaScript object notation format ( JSON )
encounter
IEncounter
Instance of class implementing  containing the calculation data.
Instance of class implementing containing the calculation data .
stream
Stream
Stream to write JSON formatted data into.
Stream to write JSON formatted data into .