Glass.Mapper.Sc.DataMappers.SitecoreFieldIEnumerableMapper.Setup C# (CSharp) Метод

Setup() публичный Метод

Sets up the data mapper for a particular property
No mapper to handle type {0} on property {1} class {2}.Formatted(type.FullName, property.Name, /// property.ReflectedType.FullName)
public Setup ( Glass.Mapper.Pipelines.DataMapperResolver.DataMapperResolverArgs args ) : void
args Glass.Mapper.Pipelines.DataMapperResolver.DataMapperResolverArgs The args.
Результат void
        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));
        }
    }

Usage Example

        public void Setup_SubMapperIsAssigned()
        {
            //Assign
            var config = new SitecoreFieldConfiguration();
            config.PropertyInfo = typeof(StubClass).GetProperty("IList");

            var mapper = new SitecoreFieldIEnumerableMapper();
            var subMapper = new SitecoreFieldDoubleMapper();

            var args = new DataMapperResolverArgs(null, config);
            args.DataMappers = new[] {subMapper};

            //Act
            mapper.Setup(args);

            //Assert
            Assert.AreEqual(subMapper, mapper.Mapper);
        }
All Usage Examples Of Glass.Mapper.Sc.DataMappers.SitecoreFieldIEnumerableMapper::Setup