private void SaveEntity(EntitySaveData data) { if (data.Data != null) { var stream = new FileStream(data.Targetname, FileMode.Create); stream.Write(data.Data, 0, data.Data.Length); stream.Close(); stream.Dispose(); } }
public void SaveEntities(ICollection <Entity> entities) { var toSave = new Dictionary <int, EntitySaveData>(); foreach (var entity in entities) { if (!ShouldSaveEntity(entity)) { continue; } var saveData = new EntitySaveData { Targetname = GetEntityTargetSaveFilename(entity), Data = GetEntityData(entity) }; if (saveData.Targetname == null) { continue; } toSave[entity.EntityId] = saveData; } if (toSave.Count == 0) { return; } lock (this) { foreach (var item in toSave) { _entitiesToSave[item.Key] = item.Value; } } }