예제 #1
0
        public Expression Remap(int offset, Dictionary <Expression, Expression> processedExpressions)
        {
            if (!CanRemap)
            {
                return(this);
            }

            Expression value;

            if (processedExpressions.TryGetValue(this, out value))
            {
                return(value);
            }

            var mapping = new Segment <int>(Mapping.Offset + offset, Mapping.Length);
            var result  = new StructureExpression(PersistentType, mapping);

            processedExpressions.Add(this, result);
            var processedFields = Fields
                                  .Select(f => f.Remap(offset, processedExpressions))
                                  .Cast <PersistentFieldExpression>()
                                  .ToList();

            result.Fields     = processedFields;
            result.IsNullable = IsNullable;
            return(result);
        }
예제 #2
0
        public static StructureExpression CreateLocalCollectionStructure(TypeInfo typeInfo, Segment <int> mapping)
        {
            if (!typeInfo.IsStructure)
            {
                throw new ArgumentException(string.Format(Strings.ExTypeXIsNotStructure, typeInfo.Name));
            }
            var result = new StructureExpression(typeInfo, mapping);

            result.Fields = typeInfo.Fields
                            .Select(f => BuildNestedFieldExpression(f, mapping.Offset))
                            .ToList();
            return(result);
        }
예제 #3
0
        public Expression RemoveOuterParameter(Dictionary <Expression, Expression> processedExpressions)
        {
            Expression value;

            if (processedExpressions.TryGetValue(this, out value))
            {
                return(value);
            }

            var result = new StructureExpression(PersistentType, Mapping);

            processedExpressions.Add(this, result);
            var processedFields = Fields
                                  .Select(f => f.RemoveOuterParameter(processedExpressions))
                                  .Cast <PersistentFieldExpression>()
                                  .ToList();

            result.Fields = processedFields;
            return(result);
        }
예제 #4
0
        public Expression Remap(int[] map, Dictionary <Expression, Expression> processedExpressions)
        {
            if (!CanRemap)
            {
                return(this);
            }

            Expression value;

            if (processedExpressions.TryGetValue(this, out value))
            {
                return(value);
            }

            var result = new StructureExpression(PersistentType, default(Segment <int>));

            processedExpressions.Add(this, result);
            var processedFields = Fields
                                  .Select(f => f.Remap(map, processedExpressions))
                                  .Where(f => f != null)
                                  .Cast <PersistentFieldExpression>()
                                  .ToList();

            if (processedFields.Count == 0)
            {
                processedExpressions[this] = null;
                return(null);
            }
            var length = processedFields.Select(f => f.Mapping.Offset).Distinct().Count();
            var offset = processedFields.Min(f => f.Mapping.Offset);

            result.Mapping    = new Segment <int>(offset, length);
            result.Fields     = processedFields;
            result.IsNullable = IsNullable;
            return(result);
        }