Пример #1
0
            static ObjectActivator CreateObjectActivator(Type type, IDataReader reader)
            {
                EntityConstructorDescriptor constructorDescriptor = EntityConstructorDescriptor.GetInstance(type.GetConstructor(Type.EmptyTypes));
                EntityMemberMapper          mapper = constructorDescriptor.GetEntityMemberMapper();
                Func <IDataReader, ReaderOrdinalEnumerator, ObjectActivatorEnumerator, object> instanceCreator = constructorDescriptor.GetInstanceCreator();
                List <IValueSetter> memberSetters = PrepareValueSetters(type, reader, mapper);

                return(new ObjectActivator(instanceCreator, null, null, memberSetters, null));
            }
Пример #2
0
            static ObjectActivator CreateObjectActivator(Type type, IDataReader reader)
            {
                ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes);

                if (constructor == null)
                {
                    throw new ArgumentException(string.Format("The type of '{0}' does't define a none parameter constructor.", type.FullName));
                }

                EntityConstructorDescriptor constructorDescriptor = EntityConstructorDescriptor.GetInstance(constructor);
                EntityMemberMapper          mapper = constructorDescriptor.GetEntityMemberMapper();
                Func <IDataReader, ReaderOrdinalEnumerator, ObjectActivatorEnumerator, object> instanceCreator = constructorDescriptor.GetInstanceCreator();
                List <IValueSetter> memberSetters = PrepareValueSetters(type, reader, mapper);

                return(new ObjectActivator(instanceCreator, null, null, memberSetters, null));
            }