/// <summary>
        /// Maps the properties to object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="service">The service.</param>
        /// <param name="context">The context.</param>
        public void MapPropertiesToObject(object obj, IAbstractService service, AbstractTypeCreationContext context)
        {
            try
            {
                //create properties
                AbstractDataMappingContext dataMappingContext = service.CreateDataMappingContext(context, obj);

                foreach (var prop in Properties)
                {
                    try
                    {
                        prop.Mapper.MapCmsToProperty(dataMappingContext);
                    }
                    catch (Exception e)
                    {
                        throw new MapperException(
                                  "Failed to map property {0} on {1}".Formatted(prop.PropertyInfo.Name,
                                                                                prop.PropertyInfo.DeclaringType.FullName), e);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new MapperException(
                          "Failed to map properties on {0}.".Formatted(context.DataSummary()), ex);
            }
        }
示例#2
0
        /// <summary>
        /// Maps the properties to object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="service">The service.</param>
        /// <param name="context">The context.</param>
        public void MapPropertiesToObject(object obj, IAbstractService service, AbstractTypeCreationContext context)
        {
            try
            {
                if (_properties.Count != 0)
                {
                    //create properties
                    AbstractDataMappingContext dataMappingContext = context.CreateDataMappingContext(obj);


                    foreach (var property in _properties.Values)
                    {
                        var prop = property;

                        try
                        {
                            prop.Mapper.MapCmsToProperty(dataMappingContext);
                        }
                        catch (MapperStackException)
                        {
                            throw;
                        }
                        catch (Exception e)
                        {
                            throw new MapperException(
                                      "Failed to map property {0} on {1}".Formatted(prop.PropertyInfo.Name,
                                                                                    prop.PropertyInfo.DeclaringType.FullName), e);
                        }
                    }
                }
            }
            catch (MapperStackException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new MapperException(
                          "Failed to map properties on {0}.".Formatted(context.DataSummary()), ex);
            }

            MapPrivatePropertiesToObject(obj, service, context);
        }
示例#3
0
        /// <summary>
        /// Maps the properties to object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="service">The service.</param>
        /// <param name="context">The context.</param>
        public void MapPropertiesToObject(object obj, IAbstractService service, AbstractTypeCreationContext context)
        {
            try
            {
                //create properties
                AbstractDataMappingContext dataMappingContext = service.CreateDataMappingContext(context, obj);
                _propertMappingExpression(obj, dataMappingContext);

                //var tasks = Properties.Select(x =>
                //    {
                //        var t = new Task(() => x.Mapper.MapCmsToProperty(dataMappingContext));
                //        t.Start();
                //        return t;
                //    });

                //Task.WaitAll(tasks.ToArray());

                //for(int i  = Properties.Length-1; i >= 0; i--)
                //{
                //    var prop = Properties[i];

                //    try
                //    {
                //        prop.Mapper.MapCmsToProperty(context);
                //    }
                //    catch (Exception e)
                //    {
                //        throw new MapperException(
                //            "Failed to map property {0} on {1}".Formatted(prop.PropertyInfo.Name,
                //                prop.PropertyInfo.DeclaringType.FullName), e);
                //    }

                //}
            }
            catch (Exception ex)
            {
                throw new MapperException(
                          "Failed to map properties on {0}.".Formatted(context.DataSummary()), ex);
            }
        }
        /// <summary>
        /// Maps the properties to object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="service">The service.</param>
        /// <param name="context">The context.</param>
        public void MapPropertiesToObject( object obj, IAbstractService service, AbstractTypeCreationContext context)
        {
            try
            {
                //create properties 
                AbstractDataMappingContext dataMappingContext = service.CreateDataMappingContext(context, obj);
                _propertMappingExpression(obj, dataMappingContext);

                //var tasks = Properties.Select(x =>
                //    {
                //        var t = new Task(() => x.Mapper.MapCmsToProperty(dataMappingContext));
                //        t.Start();
                //        return t;
                //    });

                //Task.WaitAll(tasks.ToArray());

                //for(int i  = Properties.Length-1; i >= 0; i--)
                //{
                //    var prop = Properties[i];

                //    try
                //    {
                //        prop.Mapper.MapCmsToProperty(context);
                //    }
                //    catch (Exception e)
                //    {
                //        throw new MapperException(
                //            "Failed to map property {0} on {1}".Formatted(prop.PropertyInfo.Name,
                //                prop.PropertyInfo.DeclaringType.FullName), e);
                //    }

                //}
            }
            catch (Exception ex)
            {
                throw new MapperException(
                           "Failed to map properties on {0}.".Formatted(context.DataSummary()), ex);
            }
        }
        /// <summary>
        /// Maps the properties to object.
        /// </summary>
        /// <param name="obj">The obj.</param>
        /// <param name="service">The service.</param>
        /// <param name="context">The context.</param>
        public void MapPropertiesToObject( object obj, IAbstractService service, AbstractTypeCreationContext context)
        {
            try
            {
                //create properties 
                AbstractDataMappingContext dataMappingContext = service.CreateDataMappingContext(context, obj);

                foreach (var prop in Properties)
                {
                    try
                    {
                        prop.Mapper.MapCmsToProperty(dataMappingContext);
                    }
                    catch (Exception e)
                    {
                        throw new MapperException(
                            "Failed to map property {0} on {1}".Formatted(prop.PropertyInfo.Name,
                                prop.PropertyInfo.DeclaringType.FullName), e);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new MapperException(
                           "Failed to map properties on {0}.".Formatted(context.DataSummary()), ex);
            }
        }