Пример #1
0
        // Token: 0x060015AB RID: 5547 RVA: 0x00067294 File Offset: 0x00065494
        private static Func <object[], Class_299> GetJsonConverterCreator(Type converterType)
        {
            Func <object> defaultConstructor = Class_514.HasDefaultConstructor(converterType, false) ? Class_470.ReflectionDelegateFactory.smethod_4010 <object>(converterType) : null;

            return(delegate(object[] parameters)
            {
                Class_299 result;
                try
                {
                    if (parameters != null)
                    {
                        Type[] types = (from param in parameters
                                        select param.GetType()).ToArray <Type>();
                        ConstructorInfo constructor = converterType.GetConstructor(types);
                        if (!(null != constructor))
                        {
                            throw new Class_318("No matching parameterized constructor found for '{0}'.".FormatWith(CultureInfo.InvariantCulture, converterType));
                        }
                        Class_482 <object> class_ = Class_470.ReflectionDelegateFactory.pmethod_4009(constructor);
                        result = (Class_299)class_(parameters);
                    }
                    else
                    {
                        if (defaultConstructor == null)
                        {
                            throw new Class_318("No parameterless constructor defined for '{0}'.".FormatWith(CultureInfo.InvariantCulture, converterType));
                        }
                        result = (Class_299)defaultConstructor();
                    }
                }
                catch (Exception arg_)
                {
                    throw new Class_318("Error creating '{0}'.".FormatWith(CultureInfo.InvariantCulture, converterType), arg_);
                }
                return result;
            });
        }
Пример #2
0
        // Token: 0x0600164F RID: 5711 RVA: 0x00069DA0 File Offset: 0x00067FA0
        public static Class_482 <object> BuildMapCreator <TKey, TValue>()
        {
            Type type = Class_484._mapType.MakeGenericType(new Type[]
            {
                typeof(TKey),
                typeof(TValue)
            });
            ConstructorInfo constructor = type.GetConstructor(new Type[]
            {
                typeof(IEnumerable <Tuple <TKey, TValue> >)
            });
            Class_482 <object> ctorDelegate = Class_470.ReflectionDelegateFactory.pmethod_4009(constructor);

            return(delegate(object[] args)
            {
                IEnumerable <KeyValuePair <TKey, TValue> > source = (IEnumerable <KeyValuePair <TKey, TValue> >)args[0];
                IEnumerable <Tuple <TKey, TValue> > enumerable = from kv in source
                                                                 select new Tuple <TKey, TValue>(kv.Key, kv.Value);
                return ctorDelegate(new object[]
                {
                    enumerable
                });
            });
        }