/// <summary>
        /// Writes a <see cref="Byte" /> to a new buffer.
        /// </summary>
        /// <param name="converter">The converter.</param>
        /// <param name="value">The value.</param>
        public static byte[] FromByte(this IByteConverter converter, byte value)
        {
            var buffer = new byte[1];

            converter.FromByte(value, buffer);

            return(buffer);
        }
예제 #2
0
        public virtual byte[] CreateHeader(byte[] extras, byte[] body, byte[] key)
        {
            var header      = new byte[OperationHeader.Length];
            var totalLength = extras.GetLengthSafe() + key.GetLengthSafe() + body.GetLengthSafe();

            Converter.FromByte((byte)Magic.Request, header, HeaderIndexFor.Magic);
            Converter.FromByte((byte)OperationCode, header, HeaderIndexFor.Opcode);
            Converter.FromInt16((short)key.GetLengthSafe(), header, HeaderIndexFor.KeyLength);
            Converter.FromByte((byte)extras.GetLengthSafe(), header, HeaderIndexFor.ExtrasLength);

            if (VBucket != null)
            {
                Converter.FromInt16((short)VBucket.Index, header, HeaderIndexFor.VBucket);
            }

            Converter.FromInt32(totalLength, header, HeaderIndexFor.BodyLength);
            Converter.FromUInt32(Opaque, header, HeaderIndexFor.Opaque);
            Converter.FromUInt64(Cas, header, HeaderIndexFor.Cas);

            return(header);
        }
예제 #3
0
        public static ISiteObject GetSiteObject(SiteDb SiteDb, LogEntry log)
        {
            var repo = SiteDb.GetRepository(log.StoreName);

            if (repo == null)
            {
                return(null);
            }

            var objectid = KeyConverter.FromByte(log.KeyBytes);

            var siteobject = repo.Get(objectid);

            if (siteobject == null)
            {
                siteobject = repo.GetLastEntryFromLog(objectid);
            }
            return(siteobject);
        }