public override void Save(string customSaveName = null) { using (ExecutionLock.AcquireExclusiveUsing()) { TextWriter writer = MyAPIGateway.Utilities.WriteFileInLocalStorage(Name, typeof(ChatCommandLogic)); writer.Write(CommandMessageOfTheDay.Content ?? ""); writer.Flush(); writer.Close(); } }
public override void Save(string customSaveName = null) { using (ExecutionLock.AcquireExclusiveUsing()) { var fileName = !string.IsNullOrEmpty(customSaveName) ? string.Format(Format, customSaveName) : Name; TextWriter writer = MyAPIGateway.Utilities.WriteFileInLocalStorage(fileName, typeof(ServerConfig)); writer.Write(MyAPIGateway.Utilities.SerializeToXML(PrivateConversations)); writer.Flush(); writer.Close(); } }
private void SwapStorage(ContentStorage contentStorage, bool bNotify) { ContentStorage old; using (ExecutionLock.Write(LockTimeout)) { if (bNotify) { BroadcastToOthers(Events.ContentUpdate); } old = _content; _content = contentStorage; } if (old != null) { old.Dispose(); } }
public void Dispose() { if (_content != null) { using (ExecutionLock.Write(LockTimeout)) { if (_content != null) { _content.Dispose(); } _content = null; if (_rsaKeyPair != null) { _rsaKeyPair.Dispose(); } } } }
public void ChangeStorage(ContentStorage contentStorage) { ExecutionLock.ReleaseRead(); //they already have a read-lock try { SwapStorage(contentStorage, true); } finally { try { ExecutionLock.Read(LockTimeout); } catch (Exception e) { throw new CorruptApplicationDomainException(e); } } }
public override void Save(string customSaveName = null) { using (ExecutionLock.AcquireExclusiveUsing()) { string fileName; if (!string.IsNullOrEmpty(customSaveName)) { fileName = string.Format(Format, customSaveName); } else { fileName = Name; } TextWriter writer = MyAPIGateway.Utilities.WriteFileInLocalStorage(fileName, typeof(ServerConfig)); writer.Write(MyAPIGateway.Utilities.SerializeToXML(ChatMessages)); writer.Flush(); writer.Close(); } }