Exemplo n.º 1
0
 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();
     }
 }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        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();
            }
        }
Exemplo n.º 4
0
        public void Dispose()
        {
            if (_content != null)
            {
                using (ExecutionLock.Write(LockTimeout))
                {
                    if (_content != null)
                    {
                        _content.Dispose();
                    }
                    _content = null;

                    if (_rsaKeyPair != null)
                    {
                        _rsaKeyPair.Dispose();
                    }
                }
            }
        }
Exemplo n.º 5
0
 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);
         }
     }
 }
Exemplo n.º 6
0
        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();
            }
        }