Glass.Mapper.Sc.DataMappers.SitecoreLinkedMapper.CanHandle C# (CSharp) Метод

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

Indicates that the data mapper will mapper to and from the property
public CanHandle ( AbstractPropertyConfiguration configuration, Context context ) : bool
configuration Glass.Mapper.Configuration.AbstractPropertyConfiguration The configuration.
context Context The context.
Результат bool
        public override bool CanHandle(AbstractPropertyConfiguration configuration, Context context)
        {
            if (!(configuration is SitecoreLinkedConfiguration))
                return false;

            if (!configuration.PropertyInfo.PropertyType.IsGenericType) return false;

            Type outerType = Utilities.GetGenericOuter(configuration.PropertyInfo.PropertyType);
            Type innerType = Mapper.Utilities.GetGenericArgument(configuration.PropertyInfo.PropertyType);

            return typeof (IEnumerable<>) == outerType;// && context.TypeConfigurations.ContainsKey(innerType);
        }
    }

Usage Example

        public void CanHandle_IsEnumerableOfMappedClassWithLinkedConfig_ReturnsTrue()
        {
            //Assign
            var config = new SitecoreLinkedConfiguration();
            config.PropertyInfo = new FakePropertyInfo(typeof(IEnumerable<StubMapped>));
            var mapper = new SitecoreLinkedMapper();
            var context = Context.Create(Utilities.CreateStandardResolver());
            context.Load(new SitecoreAttributeConfigurationLoader("Glass.Mapper.Sc.Integration"));


            //Act
            var result = mapper.CanHandle(config, context);
            
            //Assert
            Assert.IsTrue(result);

        }
All Usage Examples Of Glass.Mapper.Sc.DataMappers.SitecoreLinkedMapper::CanHandle