Пример #1
0
        /// <summary>
        /// Validates configurations and sets required fields
        /// </summary>
        public void Validate(DynamoDBContext context)
        {
            if (IsVersion)
            {
                Utils.ValidateVersionType(MemberType);    // no conversion is possible, so type must be a nullable primitive
            }
            if (IsHashKey && IsRangeKey)
            {
                throw new InvalidOperationException("Property " + PropertyName + " cannot be both hash and range key");
            }

            if (ConverterType != null)
            {
                if (!Utils.CanInstantiateConverter(ConverterType) || !Utils.ImplementsInterface(ConverterType, typeof(IPropertyConverter)))
                {
                    throw new InvalidOperationException("Converter for " + PropertyName + " must be instantiable with no parameters and must implement IPropertyConverter");
                }

                this.Converter = Utils.InstantiateConverter(ConverterType, context) as IPropertyConverter;
            }

            IPropertyConverter converter;

            if (context.ConverterCache.TryGetValue(MemberType, out converter) && converter != null)
            {
                this.Converter = converter;
            }

            foreach (var index in Indexes)
            {
                IndexNames.AddRange(index.IndexNames);
            }
        }