public DependentRandom(IRandom random, IRollHistorySerializer rollHistorySerializer, IDependentChanceProvider dependentChanceProvider) { _random = random; _rollHistorySerializer = rollHistorySerializer; _dependentChanceProvider = dependentChanceProvider; _rollHistoryContainer = _rollHistorySerializer.Deserialize(); }
public RollHistoryContainer Deserialize() { if (string.IsNullOrEmpty(_filePath)) { throw new ArgumentNullException(nameof(_filePath)); } var result = new RollHistoryContainer(); if (File.Exists(_filePath)) { result.HistoryStorage = Deserialize(File.Open(_filePath, FileMode.Open)); } return(result); }
public void Serialize(RollHistoryContainer rollHistoryContainer) { if (string.IsNullOrEmpty(_filePath)) { throw new ArgumentNullException(nameof(_filePath)); } if (File.Exists(_filePath)) { File.Delete(_filePath); } var directory = Path.GetDirectoryName(_filePath); if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) { Directory.CreateDirectory(directory); } Serialize(rollHistoryContainer.HistoryStorage, File.Open(_filePath, FileMode.Create)); }
public void Serialize(RollHistoryContainer rollHistoryContainer) { }