コード例 #1
0
 internal void HandleValueField(ValueField valueField, IPropertySymbol property, ImmutableArray<AttributeData> propertyAttributes)
 {
     AddKeyAttribute(property, propertyAttributes, valueField);
     AddIndexAttribute(property, propertyAttributes, valueField);
     AddMaxLengthAttribute(property, propertyAttributes, valueField);
     AddDatabaseGeneratedAttribute(property, propertyAttributes, valueField);
 }
コード例 #2
0
        private void AddDatabaseGeneratedAttribute(IPropertySymbol classProperty, IEnumerable<AttributeData> propertyAttributes, ValueField valueField)
        {
            var databaseGeneratedAttributeValue = DatabaseGeneratedAttribute.None;

            var databaseGeneratedAttribute = propertyAttributes.SingleOrDefault(a => a.AttributeClass.Name == "DatabaseGeneratedAttribute");
            if (databaseGeneratedAttribute != null)
            {
                var databaseGeneratedOption = Enum.GetName(typeof(System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption), databaseGeneratedAttribute.ConstructorArguments[0].Value);
                databaseGeneratedAttributeValue = (DatabaseGeneratedAttribute)Enum.Parse(typeof(DatabaseGeneratedAttribute), databaseGeneratedOption);
            }

            var assumption = _constraintBuilder.Assume(() => valueField.DatabaseGeneratedAttribute == databaseGeneratedAttributeValue);
            _propertyAssumptions.Add(new DatabaseGeneratedAttributePropertyAssumption(classProperty, assumption, valueField));
        }
コード例 #3
0
 private void AddMaxLengthAttribute(IPropertySymbol classProperty, IEnumerable<AttributeData> propertyAttributes, ValueField valueField)
 {
     var hasMaxLengthAttribute = propertyAttributes.Any(a => a.AttributeClass.Name == "MaxLengthAttribute");
     var assumption = _constraintBuilder.Assume(() => valueField.HasMaxLengthAttribute == hasMaxLengthAttribute);
     _propertyAssumptions.Add(new HasMaxLengthAttributePropertyAssumption(classProperty, assumption, valueField));
 }