Example #1
0
        /// <nodoc />
        public static ContentHashList FromGrpc(this ContentHashListData input)
        {
            if (input.Payload.IsEmpty && input.ContentHashes.Count == 0)
            {
                // Special case: if all the fields are empty, the result is null.
                return(null);
            }

            return(new ContentHashList(
                       input.ContentHashes.Select(ch => ch.FromGrpc()).ToArray(),
                       // Grpc does not support passing null values over the wire.
                       // To work-around this issue, the null payload is serialized as an empty array.
                       // But to preserve equality we need to use a special logic and return null if the payload is empty.
                       input.Payload.DeserializePayload()));
        }
Example #2
0
        /// <nodoc />
        public static ContentHashListData ToGrpc(this ContentHashList input)
        {
            var result = new ContentHashListData();

            if (input != null)
            {
                foreach (var hash in input.Hashes)
                {
                    result.ContentHashes.Add(hash.ToGrpc());
                }

                result.Payload = input.Payload.ToByteString();
            }

            return(result);
        }