Example #1
0
        public void AssignColumn(DataColumn dataColumn, Array classInstances)
        {
            var key = new TypeCachingKey(_classType, dataColumn.Field);

            MSILGenerator.AssignArrayDelegate assignColumn = _assignerKeyToTag.GetOrAdd(key, (_) => new MSILGenerator().GenerateAssigner(dataColumn, _classType));
            assignColumn(dataColumn, classInstances);
        }
Example #2
0
        public void AssignColumn(DataColumn dataColumn, Array classInstances)
        {
            var key = new TypeCachingKey(_classType, dataColumn.Field);

            if (!_assignerKeyToTag.TryGetValue(key, out MSILGenerator.AssignArrayDelegate assignColumn))
            {
                _assignerKeyToTag[key] = assignColumn = new MSILGenerator().GenerateAssigner(dataColumn, _classType);
            }

            assignColumn(dataColumn, classInstances);
        }
Example #3
0
        private AssignerTag GetAssignerTag(TypeCachingKey key)
        {
            if (!_assignerKeyToTag.TryGetValue(key, out AssignerTag value))
            {
                value = new AssignerTag
                {
                    Assign = CreateAssignerDelegate(key.ClassType, key.Field)
                };

                _assignerKeyToTag[key] = value;
            }

            return(value);
        }
Example #4
0
        private CollectorTag GetCollectorTag(TypeCachingKey key)
        {
            if (!_collectorKeyToTag.TryGetValue(key, out CollectorTag value))
            {
                value = new CollectorTag
                {
                    Collect = CreateCollectorDelegate(key.ClassType, key.Field)
                };

                _collectorKeyToTag[key] = value;
            }

            return(value);
        }
Example #5
0
        public DataColumn BuildColumn(DataField field, Array classInstances, int classInstancesCount)
        {
            var key = new TypeCachingKey(_classType, field);

            MSILGenerator.PopulateListDelegate populateList = _collectorKeyToTag.GetOrAdd(key, (_) => new MSILGenerator().GenerateCollector(_classType, field));

            IList      resultList    = field.ClrNullableIfHasNullsType.CreateGenericList();
            List <int> repLevelsList = field.IsArray ? new List <int>() : null;
            object     result        = populateList(classInstances, resultList, repLevelsList, field.MaxRepetitionLevel);

            MethodInfo toArrayMethod = typeof(List <>).MakeGenericType(field.ClrNullableIfHasNullsType).GetTypeInfo().GetDeclaredMethod("ToArray");
            object     array         = toArrayMethod.Invoke(resultList, null);

            return(new DataColumn(field, (Array)array, repLevelsList?.ToArray()));
        }