Пример #1
0
 /// <summary>LoadContent
 /// </summary>
 public override void LoadContent(ClusterConfiguration configuration, byte[] data)
 {
     if (data.Length != Consts.FDFS_GROUP_INFO_SIZE)
     {
         throw new ArgumentException($"返回数据长度:{data.Length},不是有效的GroupInfo数据长度.");
     }
     GroupInfo = EndecodeUtil.DecodeGroupInfo(data, configuration.Charset);
 }
Пример #2
0
        /// <summary>LoadContent
        /// </summary>
        public override void LoadContent(ClusterConfiguration configuration, byte[] data)
        {
            if (data.Length % Consts.FDFS_GROUP_INFO_SIZE != 0)
            {
                throw new ArgumentException("返回数据长度不正确,不是'FDFS_GROUP_INFO_SIZE' 的整数倍.");
            }
            var count = data.Length / Consts.FDFS_GROUP_INFO_SIZE;

            var dataSpan = data.AsSpan();

            for (int i = 0; i < count; i++)
            {
                //var buffer = new byte[Consts.FDFS_GROUP_INFO_SIZE];
                //Array.Copy(data, i * Consts.FDFS_GROUP_INFO_SIZE, buffer, 0, buffer.Length);

                var bufferSpan = dataSpan.Slice(i * Consts.FDFS_GROUP_INFO_SIZE, Consts.FDFS_GROUP_INFO_SIZE);

                var groupInfo = EndecodeUtil.DecodeGroupInfo(bufferSpan.ToArray(), configuration.Charset);
                GroupInfos.Add(groupInfo);
            }
        }