/// <summary>
        /// Builds the automatic resolver merger for compatibles properties using the given key service for dedicated context.
        /// </summary>
        /// <param name="keyService">The key service.</param>
        /// <param name="sourceType">Type of the source.</param>
        /// <param name="destinationType">Type of the destination.</param>
        /// <returns></returns>
        public bool BuildAutoResolverMerger(object keyService, Type sourceType, Type destinationType)
        {
            ISourceMerger merger = new SourceMerger(sourceType, destinationType,
                                                    FactoryMapper.GetDefaultPropertyMappers(sourceType, destinationType,
                                                                                            this));

            return(this.RegisterMerger(merger, keyService));
        }
        /// <summary>
        /// Builds the automatic resolver merger for compatibles properties using the given key service for dedicated context and actions.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="keyService">The key service.</param>
        /// <param name="beforeMapping">The before mapping.</param>
        /// <param name="afterMapping">The after mapping.</param>
        /// <returns></returns>
        public bool BuildAutoResolverMerger <TSource, TDestination>(object keyService, Action <TDestination> beforeMapping, Action <TDestination> afterMapping)
            where TSource : class
            where TDestination : class
        {
            ISourceMerger merger =
                new SourceMerger <TSource, TDestination>(
                    FactoryMapper.GetDefaultPropertyMappers <TSource, TDestination>(this), beforeMapping, afterMapping);

            return(this.RegisterMerger(merger, keyService));
        }
示例#3
0
        public void ServiceTransformerMembersTest1()
        {
            object defaultKey = KeyService.Type1;

            ISourceMerger mapper =
                new SourceMerger <Student, Person>(
                    FactoryMapper.GetDefaultPropertyMappers <Student, Person>(), null, null);

            var service = new ServiceTransformer <ISourceMerger>(defaultKey, mapper);

            Assert.IsNotNull(service);
            Assert.IsTrue(service.ServiceKey is Enum);
            Assert.AreEqual(service.ServiceKey, KeyService.Type1);
        }
示例#4
0
        public void ServiceTransformerMembersTest()
        {
            object defaultKey = " ciao ";

            ISourceMerger mapper =
                new SourceMerger <Student, Person>(
                    FactoryMapper.GetDefaultPropertyMappers <Student, Person>(), null, null);

            var service = new ServiceTransformer <ISourceMerger>(defaultKey, mapper);

            Assert.IsNotNull(service);
            Assert.IsTrue(service.ServiceKey is string);
            Assert.AreNotEqual(service.ServiceKey, " ciao");
            Assert.AreNotEqual(service.ServiceKey, "ciao ");
            Assert.AreEqual(service.ServiceKey, "ciao");
        }
        /// <summary>
        /// Makes the transformer builder following the specified builder type.
        /// </summary>
        /// <typeparam name="TSource">The type of the source.</typeparam>
        /// <typeparam name="TDestination">The type of the destination.</typeparam>
        /// <param name="type">The builder type to use.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException">Builder type not implemented by now.</exception>
        public ITransformerBuilder <TSource, TDestination> MakeTransformerBuilder <TSource, TDestination>(BuilderType type)
            where TSource : class
            where TDestination : class
        {
            switch (type)
            {
            case BuilderType.DefaultMappers:
                return(new TransformerBuilder <TSource, TDestination>(this, FactoryMapper.GetDefaultPropertyMappers <TSource, TDestination>()));

            case BuilderType.Empty:
                return(new TransformerBuilder <TSource, TDestination>(this));

            case BuilderType.DynamicResolver:
                return(new TransformerBuilder <TSource, TDestination>(this, FactoryMapper.GetDefaultPropertyMappers <TSource, TDestination>(this)));

            default:
                throw new NotImplementedException("Builder type not implemented by now.");
            }
        }