public static int WriteNamedType(ref byte[] bytes, int offset, Type type)
        {
            var typeKey      = TypeSerializer.GetTypeKeyFromType(type);
            var hashCodeSize = WriteInt32(ref bytes, offset, typeKey.HashCode);
            var typeName     = typeKey.TypeName;
            var nameSize     = WriteBytes(ref bytes, offset + hashCodeSize, typeName, 0, typeName.Length);

            return(hashCodeSize + nameSize);
        }
        protected override byte[] TranslateTypeName(Type actualType, out Type expectedType)
        {
#if !TEST40
            if (typeof(ITestMessage).GetTypeInfo().IsAssignableFrom(actualType.GetTypeInfo()))
#else
            if (typeof(ITestMessage).IsAssignableFrom(actualType))
#endif
            {
                expectedType = typeof(ITestMessage);
            }
            else
            {
                expectedType = actualType;
            }
            return(TypeSerializer.GetTypeKeyFromType(expectedType).TypeName);
        }
 protected virtual byte[] TranslateTypeName(Type actualType, out Type expectedType)
 {
     expectedType = actualType;
     return(TypeSerializer.GetTypeKeyFromType(actualType).TypeName); // StringEncoding.UTF8.GetBytes(BuildTypeName(type));
 }