private static void RegisterKnownTypes(KnownTypesRegistry knownTypesRegistry)
        {
            var types = typeof(RemoteLinq.Expression).Assembly
                        .GetExportedTypes()
                        .Except(new[]
            {
                typeof(Query),
            })
                        .Where(x => !x.IsGenericType)
                        .Where(x =>
            {
                var attributes = x.GetCustomAttributes(true);
                return(attributes.Any(a => a is SerializableAttribute) ||
                       attributes.Any(a => a is DataContractAttribute));
            });

            foreach (var type in types)
            {
                if (!knownTypesRegistry.TryRegister(type, type.Name))
                {
                    throw new InvalidOperationException($"Failed to register '{type}' as known type.");
                }
            }
        }