Commit 437b7d58 authored by Marc Gravell's avatar Marc Gravell

Add + as a concatenation operator for RedisKey, to prevent implicit conversions back and fore

parent 28e2d29b
......@@ -195,5 +195,25 @@ internal void AssertNotNull()
return BitConverter.ToString(arr);
}
}
/// <summary>
/// Concatenate two keys
/// </summary>
public static RedisKey operator +(RedisKey x, RedisKey y)
{
byte[] xVal = x.value, yVal = y.value;
// either null? yeild the other; note this includes the "both null becomes null" case
if (xVal == null) return y;
if (yVal == null) return x;
// either empty? yeild the other; note this includes the "both null becomes null" case
if (xVal.Length == 0) return y;
if (yVal.Length == 0) return x;
byte[] result = new byte[xVal.Length + yVal.Length];
Buffer.BlockCopy(xVal, 0, result, 0, xVal.Length);
Buffer.BlockCopy(yVal, 0, result, xVal.Length, yVal.Length);
return result;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment