Setup() public method

public Setup ( Mapper args ) : void
args Mapper
return void
Example #1
0
        /// <summary>
        /// Sets up the data mapper for a particular property
        /// </summary>
        /// <param name="args">The args.</param>
        /// <exception cref="Glass.Mapper.MapperException">No mapper to handle type {0} on property {1} class {2}.Formatted(type.FullName, property.Name,
        ///                                                                                        property.ReflectedType.FullName)</exception>
        public override void Setup(DataMapperResolverArgs args)
        {
            base.Setup(args);

            var scConfig = Configuration as SitecoreFieldConfiguration;

            var property = args.PropertyConfiguration.PropertyInfo;
            var type     = Glass.Mapper.Utilities.GetGenericArgument(property.PropertyType);

            var configCopy = scConfig.Copy();

            configCopy.PropertyInfo = new FakePropertyInfo(type, property.Name, property.DeclaringType);

            Mapper =
                args.DataMappers.FirstOrDefault(
                    x => x.CanHandle(configCopy, args.Context) && x is AbstractSitecoreFieldMapper)
                as AbstractSitecoreFieldMapper;


            if (Mapper == null)
            {
                throw new MapperException(
                          "No mapper to handle type {0} on property {1} class {2}".Formatted(type.FullName, property.Name,
                                                                                             property.ReflectedType.FullName));
            }

            Mapper.Setup(new DataMapperResolverArgs(args.Context, configCopy));
        }
        /// <summary>
        /// Sets up the data mapper for a particular property
        /// </summary>
        /// <param name="args">The args.</param>
        /// <exception cref="Glass.Mapper.MapperException">No mapper to handle type {0} on property {1} class {2}.Formatted(type.FullName, property.Name,
        ///                                                                                        property.ReflectedType.FullName)</exception>
        public override void Setup(DataMapperResolverArgs args)
        {
            base.Setup(args);

            var scConfig = Configuration as SitecoreFieldConfiguration;

            var property = args.PropertyConfiguration.PropertyInfo;
            var type = Glass.Mapper.Utilities.GetGenericArgument(property.PropertyType);

            var configCopy = scConfig.Copy();
            configCopy.PropertyInfo = new FakePropertyInfo(type, property.Name, property.DeclaringType);

            Mapper =
                args.DataMappers.FirstOrDefault(
                    x => x.CanHandle(configCopy, args.Context) && x is AbstractSitecoreFieldMapper) 
                    as AbstractSitecoreFieldMapper;


            if (Mapper == null)
                throw new MapperException(
                    "No mapper to handle type {0} on property {1} class {2}".Formatted(type.FullName, property.Name,
                                                                                       property.ReflectedType.FullName));

            Mapper.Setup(new DataMapperResolverArgs(args.Context, configCopy));
        }
Example #3
0
 /// <summary>
 /// Sets up the data mapper for a particular property
 /// </summary>
 /// <param name="args">The args.</param>
 public override void Setup(DataMapperResolverArgs args)
 {
     _baseMapper.Setup(args);
     base.Setup(args);
 }