public static void SaveTxt(string filename, YSection root) { #if RELEASE try { #endif _last_type = YenconType.Text; _txt_cnvtr.Save(filename, root); #if RELEASE } catch (Exception e) { Program.ShowError(e); } #endif }
public static YSection LoadBin(string filename) { #if RELEASE try { #endif _last_type = YenconType.Binary; return _bin_cnvtr.Load(filename); #if RELEASE } catch (Exception e) { Program.ShowError(e); return null; } #endif }
/// <summary> /// 指定されたファイルに指定されたヱンコンオブジェクトを書き込みます。 /// </summary> /// <param name="filename"><paramref name="obj"/>の保存先のファイル名です。</param> /// <param name="obj">保存するヱンコンオブジェクトです。</param> /// <param name="type">ヱンコンの種類です。既定でバイナリ形式です。</param> /// <exception cref="System.IO.IOException"> /// ファイルの出力に失敗した場合に発生します。 /// </exception> public static void Save(string filename, YSection obj, YenconType type = YenconType.Binary) { try { if (type == YenconType.Text) { StringConverter.Save(filename, obj); } else if (type == YenconType.Binary) { BinaryConverter.Save(filename, obj); } } catch (Exception e) { throw new IOException(string.Format(ErrorMessages.YenconFormatRecognition_IOException, filename), e); } }
public static void Save(string filename, YSection root) { #if RELEASE try { #endif if (_last_type == YenconType.Text) { _txt_cnvtr.Save(filename, root); } else if (_last_type == YenconType.Binary) { _bin_cnvtr.Save(filename, root); } else { _last_type = YenconType.Text; _txt_cnvtr.Save(filename, root); } #if RELEASE } catch (Exception e) { Program.ShowError(e); } #endif }
public static YSection Load(string filename) { #if RELEASE try { #endif _last_type = YenconFormatRecognition.GetYenconType(filename); if (_last_type == YenconType.Text) { return _txt_cnvtr.Load(filename); } else if (_last_type == YenconType.Binary) { return _bin_cnvtr.Load(filename); } else { return null; } #if RELEASE } catch (Exception e) { Program.ShowError(e); return null; } #endif }
static FileAccessor() { _txt_cnvtr = new YenconStringConverter(); _bin_cnvtr = new YenconBinaryConverter(); _last_type = YenconType.Resource; }