Exemplo n.º 1
0
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        /// <exception cref="Glass.Mapper.Configuration.ConfigurationException">Property type {0} not supported as an ID on {1}
        ///                     .Formatted(propertyInfo.PropertyType.FullName, propertyInfo.DeclaringType.FullName)</exception>
        public virtual void Configure(System.Reflection.PropertyInfo propertyInfo, IdConfiguration config)
        {
            if(!AcceptedTypes.Any(x=>propertyInfo.PropertyType == x))
                throw new ConfigurationException("Property type {0} not supported as an ID on {1}"
                    .Formatted(propertyInfo.PropertyType.FullName, propertyInfo.DeclaringType.FullName));

            config.Type = propertyInfo.PropertyType;
            base.Configure(propertyInfo, config);
        
        }
Exemplo n.º 2
0
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        /// <exception cref="Glass.Mapper.Configuration.ConfigurationException">Property type {0} not supported as an ID on {1}
        ///                     .Formatted(propertyInfo.PropertyType.FullName, propertyInfo.DeclaringType.FullName)</exception>
        public virtual void Configure(System.Reflection.PropertyInfo propertyInfo, IdConfiguration config)
        {
            if (!AcceptedTypes.Any(x => propertyInfo.PropertyType == x))
            {
                throw new ConfigurationException("Property type {0} not supported as an ID on {1}"
                                                 .Formatted(propertyInfo.PropertyType.FullName, propertyInfo.DeclaringType.FullName));
            }

            config.Type = propertyInfo.PropertyType;
            base.Configure(propertyInfo, config);
        }
Exemplo n.º 3
0
        public void Configure_RequiredTypeDifferentFromPropertyType_ExceptionThrown()
        {
            //Assign
            var type         = typeof(string);
            var attr         = new StubIdAttribute(type);
            var config       = new IdConfiguration();
            var propertyInfo = typeof(StubClass).GetProperty("Id");

            //Act
            attr.Configure(propertyInfo, config);

            //Assert
        }
Exemplo n.º 4
0
        public void Configure_DefaultValues_ConfigContainsDefaults()
        {
            //Assign
            var type         = typeof(int);
            var attr         = new StubIdAttribute(type);
            var config       = new IdConfiguration();
            var propertyInfo = typeof(StubClass).GetProperty("Id");

            //Act
            attr.Configure(propertyInfo, config);

            //Assert
            Assert.AreEqual(propertyInfo, config.PropertyInfo);
            Assert.AreEqual(type, config.Type);
        }