Пример #1
0
 public LearningObjectiveDtoBuilder(IMappingConfiguration mappingConfiguration,
                                    ILearningObjectiveStatisticsCalculator learningObjectiveStatisticsCalculator,
                                    IUserForLearningObjectiveDtoBuilder userForLearningObjectiveDtoBuilder) : base(mappingConfiguration)
 {
     this.learningObjectiveStatisticsCalculator = learningObjectiveStatisticsCalculator;
     this.userForLearningObjectiveDtoBuilder    = userForLearningObjectiveDtoBuilder;
 }
Пример #2
0
 private static Expression CreateSelect(IMappingConfiguration mappingConfiguration, Type sourceType, Type destinationType, Expression property, string methodName)
 {
     return(Expression.Call(typeof(Enumerable), methodName, new[] { destinationType },
                            Expression.Call(typeof(Enumerable), "Select",
                                            new[] { sourceType, destinationType },
                                            property, mappingConfiguration.BuildNew(sourceType, destinationType))));
 }
Пример #3
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (destinationType != typeof (string))
                return null;

            return Expression.Call(expression, "ToString", Type.EmptyTypes);
        }
Пример #4
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (!destinationType.IsAssignableFrom(expression.Type))
                return null;

            return Expression.Convert(expression, destinationType);
        }
 private static Expression CreateSelect(IMappingConfiguration mappingConfiguration, Type sourceType, Type destinationType, Expression property, string methodName)
 {
     return Expression.Call(typeof (Enumerable), methodName, new[] {destinationType},
                            Expression.Call(typeof (Enumerable), "Select",
                                            new[] {sourceType, destinationType},
                                            property, mappingConfiguration.BuildNew(sourceType, destinationType)));
 }
Пример #6
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (destinationType != expression.Type)
                return null;

            return expression;
        }
 public AniDbMetaStructureConfiguration(PluginConfiguration pluginConfiguration,
                                        IMappingConfiguration mappingConfiguration, ISources sources)
 {
     this.pluginConfiguration  = pluginConfiguration;
     this.mappingConfiguration = mappingConfiguration;
     this.sources = sources;
 }
Пример #8
0
 public UserDetailsDtoBuilder(IMappingConfiguration mappingConfiguration,
                              IUserStatisticsCalculator userStatisticsCalculator,
                              ILearningObjectiveForUserDtoBuilder learningObjectiveForUserDtoBuilder) : base(mappingConfiguration)
 {
     this.userStatisticsCalculator           = userStatisticsCalculator;
     this.learningObjectiveForUserDtoBuilder = learningObjectiveForUserDtoBuilder;
 }
Пример #9
0
        public Expression BuildAssign(Expression destination, Expression source, IMappingConfiguration configuration)
        {
            MemberInfo info = destinationMember;

            return(Expression.Assign(Expression.MakeMemberAccess(destination, info),
                                     sourceMemberResolver.BuildSource(source, info.GetMemberType(), configuration)));
        }
Пример #10
0
 public AniMetadataConfiguration(PluginConfiguration pluginConfiguration,
                                 IMappingConfiguration mappingConfiguration, ISources sources)
 {
     _pluginConfiguration  = pluginConfiguration;
     _mappingConfiguration = mappingConfiguration;
     _sources = sources;
 }
        public void ShouldReturnTransactionsWithGivenStatusCode()
        {
            var dataContextConfig = new Mock <DataContext>();

            var mappingConfigs    = new IMappingConfiguration[] { new TransactionToGetAllTransactionsResponseModelMappingConfiguration() };
            var mappingService    = new MappingService(mappingConfigs);
            var validationService = new ValidationService();

            var transactionsQueryable       = _transactions.AsQueryable();
            var transactionsDbSetMockConfig = new Mock <DbSet <Transaction> >();

            transactionsDbSetMockConfig.As <IQueryable <Transaction> >().Setup(mockSetup => mockSetup.Provider).Returns(transactionsQueryable.Provider);
            transactionsDbSetMockConfig.As <IQueryable <Transaction> >().Setup(mockSetup => mockSetup.Expression).Returns(transactionsQueryable.Expression);
            transactionsDbSetMockConfig.As <IQueryable <Transaction> >().Setup(mockSetup => mockSetup.ElementType).Returns(transactionsQueryable.ElementType);
            transactionsDbSetMockConfig.As <IQueryable <Transaction> >().Setup(mockSetup => mockSetup.GetEnumerator()).Returns(() => transactionsQueryable.GetEnumerator());

            var dbContextOptions = new DbContextOptionsBuilder <DataContext>()
                                   .UseInMemoryDatabase(databaseName: "Test")
                                   .Options;

            var dataContextMockConfig = new Mock <DataContext>(dbContextOptions);

            dataContextMockConfig.SetupGet(mockSetup => mockSetup.Transactions).Returns(() => transactionsDbSetMockConfig.Object);

            var transactionManager = new TransactionManager(dataContextMockConfig.Object, validationService, mappingService);

            var status = "D";

            var result = transactionManager.GetAllTransactionsByStatus(status);

            Assert.IsTrue(result.All(transaction => transaction.Status == status));
        }
Пример #12
0
 /// <summary>
 /// Creates a repository factory for the supplied list of domains
 /// </summary>
 public RepositoryFactory(string connectionString, IMappingConfiguration mappings, IContextConfiguration contextConfig, ILog logger)
 {
     _connectionString = connectionString;
     _mappings         = mappings;
     _contextConfig    = contextConfig;
     _logger           = logger;
 }
Пример #13
0
        public MemberAssignment BuildBind(Expression source, IMappingConfiguration configuration)
        {
            MemberInfo info       = destinationMember;
            var        expression = sourceMemberResolver.BuildSource(source, info.GetMemberType(), configuration);

            return(Expression.Bind(info, expression));
        }
Пример #14
0
 private void ApplyConventions(IMappingConfiguration <TSource, TTarget> configuration)
 {
     foreach (IMappingConvention convention in _conventions)
     {
         convention.Apply(_propertyFinder, configuration);
     }
 }
Пример #15
0
        public IMappingConfiguration GetMappingOrDefault <TSource, TTarget>(TSource source)
        {
            IMappingConfiguration mapping = null;

            TryGetMapping <TSource, TTarget>(source, out mapping);
            return(mapping);
        }
Пример #16
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="DataContext"/> class.
 /// </summary>
 /// <param name="dbConnection">The db connection.</param>
 /// <param name="contextOwnsConnection">The context owns connection.</param>
 /// <param name="mapping">The Mapping Configuration that will determine how the tables and objects interact</param>
 /// <param name="contextConfiguration">The context specific configuration that will change context level behavior</param>
 public DataContext(
     DbConnection dbConnection,
     bool contextOwnsConnection,
     IMappingConfiguration mapping,
     IContextConfiguration contextConfiguration)
     : this(dbConnection, contextOwnsConnection, mapping, contextConfiguration, new NoOpLogger())
 {
 }
Пример #17
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="DataContext"/> class.
 /// </summary>
 /// <param name="dbConnection">The db connection.</param>
 /// <param name="contextOwnsConnection">The context owns connection.</param>
 /// <param name="mapping">The Mapping Configuration that will determine how the tables and objects interact</param>
 /// <param name="log">The logger being supplied for this context ( Optional )</param>
 ///     The log.
 /// </param>
 public DataContext(
     DbConnection dbConnection,
     bool contextOwnsConnection,
     IMappingConfiguration mapping,
     ILog log)
     : this(dbConnection, contextOwnsConnection, mapping, new DefaultContextConfiguration(), log)
 {
 }
 public IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
     StorageProviderDefinition storageProviderDefinition,
     IMethodCallTransformerProvider methodCallTransformerProvider,
     ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
     IMappingConfiguration mappingConfiguration)
 {
     return(new StubDomainObjectQueryGenerator());
 }
 public IDomainObjectQueryGenerator CreateDomainObjectQueryGenerator(
     StorageProviderDefinition storageProviderDefinition,
     IMethodCallTransformerProvider methodCallTransformerProvider,
     ResultOperatorHandlerRegistry resultOperatorHandlerRegistry,
     IMappingConfiguration mappingConfiguration)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="connectionString"></param>
 /// <param name="mappings"></param>
 /// <param name="logger"></param>
 /// <param name="contextConfiguration"></param>
 /// <param name="typesConfigured"></param>
 public AggregateConfiguration(string connectionString, IMappingConfiguration[] mappings, ILog logger,
                               IContextConfiguration contextConfiguration, params Type[] typesConfigured)
 {
     ConnectionString = connectionString;
     Mappings = mappings;
     Logger = logger ?? new NoOpLogger();
     ContextConfiguration = contextConfiguration ?? new DefaultContextConfiguration();
     TypesConfigured = typesConfigured;
 }
Пример #21
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (destinationType != expression.Type)
            {
                return(null);
            }

            return(expression);
        }
Пример #22
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (!destinationType.IsAssignableFrom(expression.Type))
            {
                return(null);
            }

            return(Expression.Convert(expression, destinationType));
        }
Пример #23
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (destinationType != typeof(string))
            {
                return(null);
            }

            return(Expression.Call(expression, "ToString", Type.EmptyTypes));
        }
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (!expression.Type.IsEnumerable() || !destinationType.IsEnumerable())
                return null;

            var isArray = destinationType.IsArray;
            var sourceElementType = TypeUtils.GetElementTypeOfEnumerable(expression.Type);
            var destinationElementType = TypeUtils.GetElementTypeOfEnumerable(destinationType);
            return Expression.Convert(CreateSelect(mappingConfiguration, sourceElementType, destinationElementType, expression, isArray ? "ToArray" : "ToList"), destinationType);
        }
Пример #25
0
 public Domain(IConnectionStringConfig connString, IMappingConfiguration mappings)
 {
     ConnectionString = connString.ConnectionString;
     Mappings = mappings;
     Context = new DefaultContextConfiguration();
     Events = new List<IInterceptor>()
     {
         // Any default interceptors can go here.
     };
 }
Пример #26
0
        /// <summary>
        /// Maps a property that appears to represent the same value in <typeparamref name="TSource"/> as <typeparamref name="TTarget"/>.
        /// </summary>
        /// <param name="configuration">A mapping configuration.</param>
        /// <param name="sourcePropertyInfo">A property of <typeparamref name="TSource"/>.</param>
        /// <param name="targetPropertyInfo">A property of <typeparamref name="TTarget"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="configuration"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="sourcePropertyInfo"/> is null.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="targetPropertyInfo"/> is null.</exception>
        public void MapLikeProperties <TSource, TTarget>(IMappingConfiguration <TSource, TTarget> configuration, PropertyInfo sourcePropertyInfo, PropertyInfo targetPropertyInfo)
        {
            configuration.ThrowIfNull("configuration");
            sourcePropertyInfo.ThrowIfNull("sourcePropertyInfo");
            targetPropertyInfo.ThrowIfNull("targetPropertyInfo");

            Func <TSource, object> valueDelegate = GetPropertyGetter <TSource>(sourcePropertyInfo).Compile();

            configuration.Map(targetPropertyInfo.Name).From(valueDelegate);
        }
Пример #27
0
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="entityMapping"></param>
        public EntityMappingVisitor(IMappingConfiguration <TModel> entityMapping)
        {
            if (entityMapping == null)
            {
                throw new ArgumentNullException("entityMapping");
            }

            _entityMapping   = entityMapping;
            _propertyMappers = CreatePropertyMappers();
        }
Пример #28
0
        public BootstrapperBase(
            Assembly assembly, IRouteConfiguration route, IFilterRegistrar filter, INavigationDefinition navigation, IMappingConfiguration mapping)
        {
            this.Assembly = assembly;
            this.RouteConfigurator = route;
            this.FilterRegistrar = filter;
            this.MappingConfigurator = mapping;

            this.Navigation = navigation.Get();
        }
Пример #29
0
        /// <summary>
        /// 输出文件模板
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="template"></param>
        /// <param name="stream"></param>
        static public void OutputTemplateFile <TModel>(this ExcelTemplate <TModel> template, Stream stream, string sheetName = null) where TModel : new()
        {
            if (template == null)
            {
                throw new NullReferenceException();
            }

            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            IMappingConfiguration <TModel> mapping = template;
            var workbook = new HSSFWorkbook();

            try
            {
                var sheet        = workbook.CreateSheet(sheetName ?? GetSheetNameFromType <TModel>());
                var row          = sheet.CreateRow(0);
                var defaultStyle = workbook.CreateCellStyle();
                // 默认列样式,有边框线
                defaultStyle.BorderTop        = BorderStyle.Thin;
                defaultStyle.TopBorderColor   = NPOI.HSSF.Util.HSSFColor.Black.Index;
                defaultStyle.BorderRight      = BorderStyle.Thin;
                defaultStyle.RightBorderColor = NPOI.HSSF.Util.HSSFColor.Black.Index;
                defaultStyle.BorderBottom     = BorderStyle.Thin;
                defaultStyle.TopBorderColor   = NPOI.HSSF.Util.HSSFColor.Black.Index;
                defaultStyle.BorderLeft       = BorderStyle.Thin;
                defaultStyle.LeftBorderColor  = NPOI.HSSF.Util.HSSFColor.Black.Index;

                // 标题样式:居中、加粗、有边框线
                var headerStyle = workbook.CreateCellStyle();
                headerStyle.CloneStyleFrom(defaultStyle);
                var headerFont = workbook.CreateFont();
                headerFont.Boldweight = 600;
                headerStyle.SetFont(headerFont);
                headerStyle.Alignment = HorizontalAlignment.Center;

                foreach (var property in mapping.GetPropertyMappings())
                {
                    sheet.SetDefaultColumnStyle(property.ColumnIndex, defaultStyle);

                    var column = row.CreateCell(property.ColumnIndex, CellType.String);
                    column.SetCellValue(GetColumnNameFromProperty(property.PropertyExpression));
                    column.CellStyle = headerStyle;
                    sheet.AutoSizeColumn(property.ColumnIndex);
                }
                sheet.CreateFreezePane(0, 1);
                workbook.Write(stream);
            }
            finally
            {
                workbook.Close();
            }
        }
Пример #30
0
        public IMappingProvider AddConfig(IMappingConfiguration config)
        {
            EnsureNoMapper();
            if (Configurations.Contains(config))
            {
                throw new Exception($"A configuration between [{config.Job.Input.FullName}] and [{config.Job.Output.FullName}] has already been added.");
            }

            Configurations.Add(config);
            return(this);
        }
Пример #31
0
 public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
 {
     try
     {
         return Expression.Convert(expression, destinationType);
     }
     catch (InvalidOperationException)
     {
     }
     return null;
 }
Пример #32
0
 /// <summary>
 /// Constructs a context
 /// </summary>
 /// <param name="connectionString">The standard SQL connection string for the Database</param>
 /// <param name="mapping">The Mapping Configuration that will determine how the tables and objects interact</param>
 /// <param name="contextConfiguration">The context specific configuration that will change context level behavior</param>
 /// <param name="log">The logger being supplied for this context ( Optional )</param>
 public DataContext(string connectionString, IMappingConfiguration mapping,
                    IContextConfiguration contextConfiguration, ILog log)
     : base(connectionString)
 {
     _mapping = mapping;
     _log     = log;
     if (contextConfiguration != null)
     {
         contextConfiguration.ConfigureContext(this);
     }
 }
Пример #33
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration cfg)
        {
            var sources = resolvers
                .Select(r => r.BuildSource(expression, destinationType, this))
                .Where(s => s != null);

            foreach (var source in sources)
                return source;

            throw new KeyNotFoundException(Tuple.Create(expression.Type, destinationType).ToString());
        }
Пример #34
0
 /// <summary>
 /// Applies the specified <see cref="IMappingConfiguration"/>
 /// </summary>
 /// <param name="profile">The <see cref="Profile"/> to configure</param>
 /// <param name="configuration">The <see cref="IMappingConfiguration"/> to apply</param>
 public static void ApplyConfiguration(this Profile profile, IMappingConfiguration configuration)
 {
     foreach (Type configurationType in configuration.GetType()
              .GetInterfaces()
              .Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IMappingConfiguration <,>)))
     {
         Type sourceType      = configurationType.GetGenericArguments()[0];
         Type destinationType = configurationType.GetGenericArguments()[1];
         GenericApplyConfigurationMethod.MakeGenericMethod(sourceType, destinationType).Invoke(null, new object[] { profile, configuration });
     }
 }
Пример #35
0
 public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
 {
     try
     {
         return(Expression.Convert(expression, destinationType));
     }
     catch (InvalidOperationException)
     {
     }
     return(null);
 }
Пример #36
0
 public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
 {
     const string name = "src";
     ParameterExpression source = Expression.Parameter(typeMap.SourceType, name);
     MemberAssignment[] bindings = typeMap.PropertyMaps
         .Select(m => m.BuildBind(source, configuration))
         .ToArray();
     return Expression.Lambda(
         Expression.Condition(Expression.Equal(source, Expression.Constant(null)),
                              Expression.Default(typeMap.DestinationType),
                              Expression.MemberInit(Expression.New(typeMap.DestinationType), bindings)), source);
 }
 public Expression BuildSource(Expression x, Type destinationType, IMappingConfiguration mappingConfiguration)
 {
     Expression expression = x;
     Expression condition = Expression.Constant(false);
     foreach (var resolver in resolvers)
     {
         if (expression.Type.IsValueType == false || expression.Type.IsNullable())
             condition = Expression.OrElse(condition, Expression.Equal(expression, Expression.Constant(null)));
         expression = resolver.BuildSource(expression, destinationType, mappingConfiguration);
     }
     return Expression.Condition(condition, Expression.Default(expression.Type), expression, expression.Type);
 }
Пример #38
0
 /// <summary>
 ///     Constructs a context
 /// </summary>
 /// <param name="connectionString">The standard SQL connection string for the Database</param>
 /// <param name="mapping">The Mapping Configuration that will determine how the tables and objects interact</param>
 /// <param name="contextConfiguration">The context specific configuration that will change context level behavior</param>
 /// <param name="log">The logger being supplied for this context ( Optional )</param>
 public UnitOfWork(string connectionString, IMappingConfiguration mapping,
                   IUnitOfWorkConfiguration contextConfiguration, ILog log)
     : base(connectionString)
 {
     _mapping          = mapping;
     _log              = log;
     this.Database.Log = _log.Debug;
     if (contextConfiguration != null)
     {
         contextConfiguration.ConfigureContext(this);
     }
 }
Пример #39
0
        public static void SetCurrent(IMappingConfiguration mappingConfiguration)
        {
            if (mappingConfiguration != null)
            {
                if (!mappingConfiguration.ResolveTypes)
                {
                    throw CreateArgumentException("mappingConfiguration", "Argument 'mappingConfiguration' must have property 'ResolveTypes' set.");
                }
            }

            s_mappingConfiguration.Value = mappingConfiguration;
        }
Пример #40
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (!expression.Type.IsEnumerable() || !destinationType.IsEnumerable())
            {
                return(null);
            }

            var isArray                = destinationType.IsArray;
            var sourceElementType      = TypeUtils.GetElementTypeOfEnumerable(expression.Type);
            var destinationElementType = TypeUtils.GetElementTypeOfEnumerable(destinationType);

            return(Expression.Convert(CreateSelect(mappingConfiguration, sourceElementType, destinationElementType, expression, isArray ? "ToArray" : "ToList"), destinationType));
        }
Пример #41
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration cfg)
        {
            var sources = resolvers
                          .Select(r => r.BuildSource(expression, destinationType, this))
                          .Where(s => s != null);

            foreach (var source in sources)
            {
                return(source);
            }

            throw new KeyNotFoundException(Tuple.Create(expression.Type, destinationType).ToString());
        }
Пример #42
0
        public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
        {
            const string        name   = "src";
            ParameterExpression source = Expression.Parameter(typeMap.SourceType, name);

            MemberAssignment[] bindings = typeMap.PropertyMaps
                                          .Select(m => m.BuildBind(source, configuration))
                                          .ToArray();
            return(Expression.Lambda(
                       Expression.Condition(Expression.Equal(source, Expression.Constant(null)),
                                            Expression.Default(typeMap.DestinationType),
                                            Expression.MemberInit(Expression.New(typeMap.DestinationType), bindings)), source));
        }
 public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
 {
     const string name = "src";
     ParameterExpression source = Expression.Parameter(typeMap.SourceType, name);
     ParameterExpression destination = Expression.Parameter(typeMap.DestinationType, "dst");
     Expression[] bindings = typeMap.PropertyMaps
         .Select(m => m.BuildAssign(destination, source, configuration))
         .Concat(new[] {destination})
         .ToArray();
     return Expression.Lambda(
         Expression.Block(bindings),
         source,
         destination);
 }
Пример #44
0
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            var map = userDefinedConfiguration.FindTypeMapConfiguration(expression.Type, destinationType);
            if (map == null)
                return null;

            if (processed.Add(map) == false || map.HasIncludes() == false)
            {
                var typeMap = CreateOrGetTypeMap(map);
                var lambda = newObjectMapperBuilder.Build(typeMap, mappingConfiguration);
                return new ParameterRewriter(lambda.Parameters[0], expression).Visit(lambda.Body);
            }

            var typeMaps = GetTypeMapsWithIncludes(map).ToArray();
            var dynamicMapper = DynamicMapperBuilder.BuildDynamicMapperType(typeMaps);
            var instance = Activator.CreateInstance(dynamicMapper, mappingConfiguration);
            return Expression.Convert(Expression.Call(Expression.Constant(instance), "DynamicMap", Type.EmptyTypes, expression), destinationType);
        }
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (!expression.Type.IsDictionary() || !destinationType.IsDictionary())
            {
                return null;
            }

            var sourceElementType = TypeUtils.GetElementTypeOfEnumerable(expression.Type);
            var destinationElementType = TypeUtils.GetElementTypeOfEnumerable(destinationType);

            var parameter = Expression.Parameter(sourceElementType, "src");

            var destinationKeyType = destinationElementType.GetProperty("Key").PropertyType;
            var destinationValueType = destinationElementType.GetProperty("Value").PropertyType;

            return Expression.Call(typeof(Enumerable), "ToDictionary", new[] { sourceElementType, destinationKeyType, destinationValueType },
                                   expression,
                                   CreateSelector(mappingConfiguration, destinationKeyType, parameter, "Key"),
                                   CreateSelector(mappingConfiguration, destinationValueType, parameter, "Value"));
        }
        public Expression BuildSource(Expression expression, Type destinationType, IMappingConfiguration mappingConfiguration)
        {
            if (!destinationType.IsDictionary())
            {
                return null;
            }

            var destinationElementType = TypeUtils.GetElementTypeOfEnumerable(destinationType);

            var add = destinationType.GetMethod("Add");
            var destinationKeyType = destinationElementType.GetProperty("Key").PropertyType;
            var destinationValueType = destinationElementType.GetProperty("Value").PropertyType;

            IEnumerable<ElementInit> initializers = expression.Type.GetReadableMembers()
                .Where(m => !excluded.Contains(m.Name))
                .Where(m => !IsPropertyGetter(m))
                .Select(property => Expression.ElementInit(add,
                    BuildSource(mappingConfiguration, destinationKeyType, Expression.Constant(property.Name)),
                    BuildSource(mappingConfiguration, destinationValueType, ExpressionEx.Member(expression, property))));

            return Expression.ListInit(Expression.New(destinationType), initializers);
        }
        public void Setup()
        {
            fooMapping = MockRepository.GenerateMock<IMappingConfiguration>();
            fooMapping.Expect(
                m =>
                m.ConfigureModelBuilder(Arg<DbModelBuilder>.Is.Anything)).Repeat.Once();
            
            barMapping = MockRepository.GenerateMock<IMappingConfiguration>();
            barMapping.Expect(
                m =>
                m.ConfigureModelBuilder(Arg<DbModelBuilder>.Is.Anything)).Repeat.Once();

            bazMapping = MockRepository.GenerateMock<IMappingConfiguration>();
            bazMapping.Expect(
                m =>
                m.ConfigureModelBuilder(Arg<DbModelBuilder>.Is.Anything)).Repeat.Once();

            quxMapping = MockRepository.GenerateMock<IMappingConfiguration>();
            quxMapping.Expect(
                m =>
                m.ConfigureModelBuilder(Arg<DbModelBuilder>.Is.Anything)).Repeat.Once();


        }
	    public Expression BuildSource(Expression x, Type destinationType, IMappingConfiguration mappingConfiguration)
	    {
	        return new ParameterRewriter(sourceMember.Parameters[0], x).Visit(sourceMember.Body);
	    }
Пример #49
0
 public POIResource(IPOIRepository POIRepository, IMappingConfiguration mappingConfiguration)
 {
     _POIRepository = POIRepository;
     mappingConfiguration.Load();
 }
Пример #50
0
        public Expression BuildAssign(Expression destination, Expression source, IMappingConfiguration configuration)
		{
			MemberInfo info = destinationMember;
			return Expression.Assign(Expression.MakeMemberAccess(destination, info),
			                         sourceMemberResolver.BuildSource(source, info.GetMemberType(), configuration));
		}
 public MigrationsDataContext(string connectionString, IMappingConfiguration mapping, IContextConfiguration contextConfiguration)
     : base(connectionString, mapping, contextConfiguration)
 {
 }
Пример #52
0
 public TestDataContext(string connectionString, IMappingConfiguration[] configurations) : base(connectionString, configurations)
 {
 }
 public LambdaExpression Build(TypeMap typeMap, IMappingConfiguration configuration)
 {
     var tuple = Tuple.Create(typeMap.SourceType, typeMap.DestinationType);
     return concurrentDictionary.GetOrAdd(tuple, k => inner.Build(typeMap, configuration));
 }
Пример #54
0
 public HighwayDataContext(string connectionString, IMappingConfiguration mapping, IContextConfiguration contextConfiguration, ILog log)
     : base(connectionString, mapping, contextConfiguration, log)
 {
 }
Пример #55
0
 public TestDataContext(string connectionString, IMappingConfiguration mapping, ILog logger)
     : base(connectionString, mapping, null, logger)
 {
 }
 public MigrationsDataContext(string connectionString, IMappingConfiguration mapping, ILog log)
     : base(connectionString, mapping, log)
 {
 }
Пример #57
0
 public HighwayDataContext(string connectionString, IMappingConfiguration mapping)
     : base(connectionString, mapping)
 {
 }
Пример #58
0
 public BeaconResource(IBeaconRepository beaconRepository, IMappingConfiguration mappingConfiguration)
 {
     _beaconRepository = beaconRepository;
     mappingConfiguration.Load();
 }
Пример #59
0
 public Expression BuildSource(Expression x, Type destinationType, IMappingConfiguration mappingConfiguration)
 {
     return ExpressionEx.Member(x, memberInfo);
 }
Пример #60
0
		public MemberAssignment BuildBind(Expression source, IMappingConfiguration configuration)
		{
			MemberInfo info = destinationMember;
		    var expression = sourceMemberResolver.BuildSource(source, info.GetMemberType(), configuration);
		    return Expression.Bind(info, expression);
		}