示例#1
0
        internal void Validate(Type implementationType)
        {
            this.FillPropertyChain(implementationType, true);

            PropertyInfo property = PropertyChain.Last();

            foreach (Type implementedInterface in new Type[] { property.PropertyType }.Concat(property.PropertyType.GetInterfaces()))
            {
                if (implementedInterface.IsGenericType && (implementedInterface.GetGenericTypeDefinition() == typeof(ICollection <>)))
                {
                    this.CollectionElementType = implementedInterface.GetGenericArguments()[0];

                    this.CollectionType = PropertyCollectionType.GenericCollection;

                    break;
                }
            }

            if (this.CollectionType == PropertyCollectionType.None)
            {
                throw new ConfigurationErrorsException(
                          "Implementation type '{0}' collection property '{1}' of type '{2}' is not supported.".FormatInvariant(implementationType, this.PropertyName, property.PropertyType),
                          this.ElementInformation.Source,
                          this.ElementInformation.LineNumber);
            }
        }
        internal void ConvertValue(Type implementationType)
        {
            this.FillPropertyChain(implementationType, false);

            ConfigurationExtensions.ConvertValue(this, PropertyChain.Last().PropertyType);
        }
示例#3
0
 public PropertyExpressionToken AllButLast(out string lastName)
 {
     lastName = PropertyChain.Last().StringValue;
     return(new PropertyExpressionToken(PropertyChain.Take(PropertyChain.Length - 1).ToArray(), StartIndex));
 }