private static Func <object[]?, object> GetCreator(Type type)
        {
            Func <object>?defaultConstructor =
                (ReflectionUtils.HasDefaultConstructor(type, false))
                    ? ReflectionDelegateFactory.CreateDefaultConstructor <object>(type)
                    : null;

            return((parameters) =>
            {
                try
                {
                    if (parameters != null)
                    {
                        Type[] paramTypes = parameters
                                            .Select(
                            param =>
                        {
                            if (param == null)
                            {
                                throw new InvalidOperationException(
                                    "Cannot pass a null parameter to the constructor."
                                    );
                            }

                            return param.GetType();
                        }
                            )
                                            .ToArray();
                        ConstructorInfo parameterizedConstructorInfo = type.GetConstructor(
                            paramTypes
                            );

                        if (parameterizedConstructorInfo != null)
                        {
                            ObjectConstructor <object> parameterizedConstructor =
                                ReflectionDelegateFactory.CreateParameterizedConstructor(
                                    parameterizedConstructorInfo
                                    );
                            return parameterizedConstructor(parameters);
                        }
                        else
                        {
                            throw new JsonException(
                                "No matching parameterized constructor found for '{0}'.".FormatWith(
                                    CultureInfo.InvariantCulture,
                                    type
                                    )
                                );
                        }
                    }

                    if (defaultConstructor == null)
                    {
                        throw new JsonException(
                            "No parameterless constructor defined for '{0}'.".FormatWith(
                                CultureInfo.InvariantCulture,
                                type
                                )
                            );
                    }

                    return defaultConstructor();
                }
                catch (Exception ex)
                {
                    throw new JsonException(
                        "Error creating '{0}'.".FormatWith(CultureInfo.InvariantCulture, type),
                        ex
                        );
                }
            });
        }
        private static Func <object[], object> GetCreator(Type type)
        {
            Func <object> defaultConstructor = ReflectionUtils.HasDefaultConstructor(type, false) ? ReflectionDelegateFactory.CreateDefaultConstructor <object>(type) : null;

            return(delegate(object[] parameters) {
                object obj2;
                try
                {
                    if (parameters != null)
                    {
                        if (< > c.< > 9__20_1 == null)
                        {
                        }
                        Type[] types = parameters.Select <object, Type>((< > c.< > 9__20_1 = new Func <object, Type>(< > c.< > 9. < GetCreator > b__20_1))).ToArray <Type>();
                        ConstructorInfo constructor = type.GetConstructor(types);
                        if (null == constructor)
                        {
                            throw new JsonException("No matching parameterized constructor found for '{0}'.".FormatWith(CultureInfo.InvariantCulture, type));
                        }
                        return ReflectionDelegateFactory.CreateParameterizedConstructor(constructor)(parameters);
                    }
                    if (defaultConstructor == null)
                    {
                        throw new JsonException("No parameterless constructor defined for '{0}'.".FormatWith(CultureInfo.InvariantCulture, type));
                    }
                    obj2 = defaultConstructor();
                }
                catch (Exception exception)
                {
                    throw new JsonException("Error creating '{0}'.".FormatWith(CultureInfo.InvariantCulture, type), exception);
                }
                return obj2;
            });
        }