private static bool TryRecursive(Type type, out ReadValueDelegate readValue, out WriteValueDelegate writeValue)
        {
            var cache = BinarySerializerCache.InternalRegisterTypes(type);

            if (cache == null)
            {
                foreach (var typeConverter in BinarySerializerCache.TypeConverterCache.Values)
                {
                    if (typeConverter.CanConvertTo(typeof(byte[])) && typeConverter.CanConvertFrom(type))
                    {
                        readValue = (deserializer, reader) =>
                        {
                            var buffer = ReadVarBytes(reader, 100);
                            return(typeConverter.ConvertFrom(null, CultureInfo.InvariantCulture, buffer));
                        };
                        writeValue = (serializer, writer, value) =>
                        {
                            var buffer = (byte[])typeConverter.ConvertTo(value, typeof(byte[]));
                            return(WriteVarBytes(writer, buffer));
                        };
                        return(true);
                    }
                }

                readValue  = null;
                writeValue = null;
                return(false);
            }

            var r = new RecursiveType(type);

            readValue  = r.GetRecursiveValue;
            writeValue = r.SetRecursiveValue;
            return(true);
        }
        internal static bool TryRecursive(MemberInfo member, Type type, out IBinaryCustomSerializable serializer, int maxLength)
        {
            // Default types

            var serializerAttr = member?.GetCustomAttribute <BinaryTypeSerializerAttribute>();

            if (serializerAttr == null)
            {
                serializerAttr = type.GetCustomAttribute <BinaryTypeSerializerAttribute>();
            }

            if (serializerAttr != null)
            {
                serializer = serializerAttr.Create(); return(true);
            }
            else if (type == typeof(string))
            {
                serializer = new BinaryStringSerializer(maxLength);
                return(true);
            }
            else if (type == typeof(long))
            {
                serializer = new BinaryInt64Serializer();
                return(true);
            }
            else if (type == typeof(ulong))
            {
                serializer = new BinaryUInt64Serializer();
                return(true);
            }
            else if (type == typeof(int))
            {
                serializer = new BinaryInt32Serializer();
                return(true);
            }
            else if (type == typeof(uint))
            {
                serializer = new BinaryUInt32Serializer();
                return(true);
            }
            else if (type == typeof(short))
            {
                serializer = new BinaryInt16Serializer();
                return(true);
            }
            else if (type == typeof(ushort))
            {
                serializer = new BinaryUInt16Serializer();
                return(true);
            }
            else if (type == typeof(byte))
            {
                serializer = new BinaryByteSerializer();
                return(true);
            }
            else if (type == typeof(sbyte))
            {
                serializer = new BinarySByteSerializer();
                return(true);
            }
            else if (type == typeof(bool))
            {
                serializer = new BinaryBoolSerializer();
                return(true);
            }
            else if (type == typeof(double))
            {
                serializer = new BinaryDoubleSerializer();
                return(true);
            }

            // Search in cache

            var cache = BinarySerializerCache.InternalRegisterTypes(type);

            if (cache == null)
            {
                serializer = null;
                return(false);
            }

            serializer = new RecursiveCustomSerializer(type);
            return(true);
        }