Example #1
0
        /// <summary>
        /// Defines the encoding method to use for the server.
        /// </summary>
        /// <param name="encoding"></param>
        public void SetEncodingMode(EncodingDefinition encoding)
        {
            m_encodingMode = Library.CreateStreamEncoding <TKey, TValue>(encoding);
            m_stream.Write((byte)ServerCommand.SetEncodingMethod);
            encoding.Save(m_stream);
            m_stream.Flush();

            var command = (ServerResponse)m_stream.ReadUInt8();

            switch (command)
            {
            case ServerResponse.UnhandledException:
                string exception = m_stream.ReadString();
                throw new Exception("Server UnhandledExcetion: \n" + exception);

            case ServerResponse.UnknownEncodingMethod:
                throw new Exception("Server does not recgonize encoding method");

            case ServerResponse.EncodingMethodAccepted:
                break;

            default:
                throw new Exception("Unknown server response: " + command.ToString());
            }
        }
 public override void Save(Stream stream)
 {
     stream.Write((byte)1);
     stream.Write(m_rolloverInterval);
     stream.Write(m_rolloverSizeMb);
     stream.Write(m_maximumAllowedMb);
     m_finalSettings.Save(stream);
     m_encodingMethod.Save(stream);
 }
        /// <summary>
        /// Writes the first page of the SortedTree as long as the <see cref="IsDirty"/> flag is set.
        /// After returning, the IsDirty flag is cleared.
        /// </summary>
        public void SaveHeader(BinaryStreamBase stream)
        {
            if (!IsDirty)
            {
                return;
            }
            long oldPosotion = stream.Position;

            stream.Position = 0;
            stream.Write((byte)1);
            stream.Write(BlockSize);
            TreeNodeType.Save(stream);
            stream.Write(LastAllocatedBlock);
            stream.Write(RootNodeIndexAddress); //Root Index
            stream.Write(RootNodeLevel);        //Root Index

            stream.Position = oldPosotion;
            m_isDirty       = false;
        }
Example #4
0
 public override void Save(Stream stream)
 {
     stream.Write((byte)1);
     stream.Write((int)m_directoryMethod);
     stream.Write(m_prefix);
     stream.Write(m_pendingExtension);
     stream.Write(m_finalExtension);
     stream.Write(m_desiredRemainingSpace);
     m_encodingMethod.Save(stream);
     stream.Write(m_writePath.Count);
     foreach (var path in m_writePath)
     {
         stream.Write(path);
     }
     stream.Write(m_flags.Count);
     foreach (var flag in m_flags)
     {
         stream.Write(flag);
     }
 }