Archive Browser
Download ChemotaxisSimulation.zip, last updated 02/11/2020 (529.88 KB)
Download- md5: d0f0a74f8f3c043fabf60aeb07356f69
- sha1: 645a77d0f7184873fe70c2bb375833e564b348be
- sha256: da9ab3cfc5e17e120b6660a137012b6eca68a7a3218cb213b3e0e3eb9445b104
using System.IO;
using YamlDotNet.Serialization;
// Simulating Bacterial Chemotaxis
// https://www.cyotek.com/blog/simulating-bacterial-chemotaxis
// Copyright © 2020 Cyotek Ltd. All Rights Reserved.
// This work is licensed under the MIT License.
// See LICENSE.TXT for the full text
// Found this example useful?
// https://www.paypal.me/cyotek
namespace Cyotek.ChemotaxisSimulation.Serialization
{
public static class SimulationSerializer
{
#region Public Methods
public static Simulation LoadFrom(string fileName)
{
using (Stream stream = File.OpenRead(fileName))
{
return SimulationSerializer.LoadFrom(stream);
}
}
public static Simulation LoadFrom(Stream stream)
{
using (TextReader reader = new StreamReader(stream, Encoding.UTF8NoIdentifier))
{
return SimulationSerializer.LoadFrom(reader);
}
}
public static Simulation LoadFrom(TextReader reader)
{
return new DeserializerBuilder()
.Build()
.Deserialize<Simulation>(reader);
}
public static void Save(Stream stream, Simulation simulation)
{
using (TextWriter writer = new StreamWriter(stream, Encoding.UTF8NoIdentifier))
{
SimulationSerializer.Save(writer, simulation);
}
}
public static void Save(TextWriter writer, Simulation simulation)
{
new SerializerBuilder()
.ConfigureDefaultValuesHandling(DefaultValuesHandling.OmitNull)
.DisableAliases()
.IgnoreFields()
.WithTypeConverter(new PointYamlTypeConverter())
.WithTypeConverter(new SizeYamlTypeConverter())
.Build()
.Serialize(writer, simulation);
}
#endregion Public Methods
}
}
Donate
This software may be used free of charge, but as with all free software there are costs involved to develop and maintain.
If this site or its services have saved you time, please consider a donation to help with running costs and timely updates.
Donate