Class AbstractSitecoreFieldMapper
Inheritance: AbstractDataMapper
Exemplo n.º 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 fieldConfiguration = this.Configuration as SitecoreFieldConfiguration;

            PropertyInfo propertyInfo = args.PropertyConfiguration.PropertyInfo;

            Type[] genericArguments = propertyInfo.PropertyType.GetGenericArguments();

            this.KeyMapper = this.GetMapper(genericArguments[0], fieldConfiguration, propertyInfo, args);

            this.ValueMapper = this.GetMapper(genericArguments[1], fieldConfiguration, propertyInfo, args);
        }
        /// <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 fieldConfiguration = this.Configuration as SitecoreFieldConfiguration;
            
            PropertyInfo propertyInfo = args.PropertyConfiguration.PropertyInfo;

            Type[] genericArguments = propertyInfo.PropertyType.GetGenericArguments();
            
            this.KeyMapper = this.GetMapper(genericArguments[0], fieldConfiguration, propertyInfo, args);

            this.ValueMapper = this.GetMapper(genericArguments[1], fieldConfiguration, propertyInfo, args);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SitecoreFieldNullableMapper{T, TMapper}"/> class.
 /// </summary>
 public SitecoreFieldNullableMapper() : base(typeof(Nullable <T>))
 {
     _baseMapper = new TMapper();
 }