public string SaveTrackItem(out ITrackItemCache nextStatus, string path) { // ファイルを作成してみて保存パス名を決める string fileName = string.Empty; for (int index = 1; index < int.MaxValue; ++index) { fileName = string.Format("TrackItem{0:D4}.dat", index); try { string savePath = Path.Combine(path, fileName); using (Stream stream = new FileStream(savePath, FileMode.CreateNew)) { stream.SetLength(0); stream.Flush(); using (TrackItemWriter tiw = new TrackItemWriter(stream)) { // 保存します tiw.Write(_item); // ファイルが作成できたからこれをファイル名にします。 _fileName = fileName; break; } } } catch (IOException) { // ファイル名が作成できないみたいだらから continue; } } nextStatus = new TrackItemCacheLoaded(_item, _fileName); return(_fileName); }
public void UpdateTrackItem(out ITrackItemCache nextStatus, string path) { nextStatus = this; // 保存されていないのですから、ここでは更新しません。 return; }
public string SaveTrackItem(out ITrackItemCache nextStatus, string path) { nextStatus = this; // もともとあるものをロードされているので、ここでは保存しない return(_fileName); }
public TrackItem GetTrackItem(out ITrackItemCache nextStatus) { string filePath = System.IO.Path.Combine(_savePath, _fileName); using (TrackItemReader tir = new TrackItemReader(filePath)) { _item = tir.Read(); } nextStatus = new TrackItemCacheLoaded(_item, _fileName); return(_item); }
public TrackItemSummary(SerializationInfo info, StreamingContext context) { ID = GenerateID(); int version = info.GetInt32("Version"); PointCount = info.GetInt32("PointCount"); From = info.GetDateTime("From"); To = info.GetDateTime("To"); _name = info.GetString("Name"); Description = info.GetString("Description"); _saveFileName = info.GetString("saveFileName"); _trackItemProxy = new TrackItemCacheNotLoaded(_savePath, _saveFileName); }
public string SaveTrackItem(out ITrackItemCache nextStatus, string path) { // 上書き保存 string savaPath = Path.Combine(path, this._fileName); using (Stream stream = new FileStream(savaPath, FileMode.Create, FileAccess.Write)) { stream.SetLength(0); stream.Flush(); using (TrackItemWriter tiw = new TrackItemWriter(stream)) { // 保存します tiw.Write(_item); } } nextStatus = new TrackItemCacheLoaded(_item, _fileName); return(_fileName); }
/// <summary> /// リカバリー用コンストラクタ /// </summary> /// <param name="track">リカバリーデータ</param> /// <param name="filePath">リカバリー元のファイル</param> public TrackItemSummary(bykIFv1.TrackItem track, string filePath) { track.Normalize(); PointCount = track.Items.Count; From = track.Items[0].Time; TimeSpan span = System.TimeZoneInfo.Local.GetUtcOffset(From); From = From.Add(span); To = track.Items[PointCount - 1].Time; span = System.TimeZoneInfo.Local.GetUtcOffset(To); To = To.Add(span); Description = track.Description; _name = track.Name; _trackItemProxy = new TrackItemCacheLoaded(track, filePath); _saveFileName = filePath; }
public TrackItemSummary(bykIFv1.TrackItem track) { track.Normalize(); ID = GenerateID(); PointCount = track.Items.Count; From = track.Items[0].Time; TimeSpan span = System.TimeZoneInfo.Local.GetUtcOffset(From); From = From.Add(span); To = track.Items[PointCount - 1].Time; span = System.TimeZoneInfo.Local.GetUtcOffset(To); To = To.Add(span); Description = track.Description; _name = track.Name; _trackItemProxy = new TrackItemCacheNotYetSaved(track); _saveFileName = string.Empty; }
public TrackItem GetTrackItem(out ITrackItemCache nextStatus) { nextStatus = this; return(this._item); }
public void UpdateTrackItem(out ITrackItemCache nextStatus, string path) { nextStatus = new TrackItemCacheModified(_item, _fileName); // 処理なし return; }
public void UpdateTrackItem(out ITrackItemCache nextStatus, string path) { nextStatus = this; // 処理なし return; }
public void UpdateTrackItem(out ITrackItemCache nextStatus, string path) { throw new Exception("未ロードから変更へは状態を更新できません。"); }
public string SaveTrackItem(out ITrackItemCache nextStatus, string path) { nextStatus = this; return(_fileName); }