public void Save(IReadOnlyDataSet instance, string filePath) { if (instance == null) { return; } BinaryFormatter bFormatter = new BinaryFormatter(); using (var fStream = new FileStream( filePath + FileExtension, FileMode.Create, FileAccess.Write, FileShare.None)) { bFormatter.Serialize(fStream, instance); } }
public static string ToDataString(this IReadOnlyDataSet dataSet) { string s = string.Concat(LineIndent.Current.Value, "Інформація про \"Хвороби\"\n"); LineIndent.Current.Increase(); s += dataSet.DicaseTypes.ToLineList( "Вид хвороби"); s += dataSet.Discases.ToLineList( "Залеижні хвороби"); s += dataSet.Patcients.ToLineList( "Пацієнти"); LineIndent.Current.Decrease(); return(s); }
public void Save(IReadOnlyDataSet dataSet, string filePath) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.Unicode; using (XmlWriter writer = XmlWriter.Create( filePath + FileExtension, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("PatcientInfo"); WriteDicaseTypes(dataSet.DicaseTypes, writer); WriteDiscases(dataSet.Discases, writer); WritePatcients(dataSet.Patcients, writer); writer.WriteEndElement(); writer.WriteEndDocument(); }; }
public static void SaveAsText( this IReadOnlyDataSet dataSet, string filePath) { File.WriteAllText(filePath, dataSet.ToDataString(), Encoding.Unicode); }