Beispiel #1
0
        public IEnumerable <KeyValuePair <string, object> > GetMetadata(FieldGenerationContext fieldGenerationContext)
        {
            if (fieldGenerationContext == null)
            {
                throw new ArgumentNullException(nameof(fieldGenerationContext));
            }

            var propertyType = fieldGenerationContext.FieldDescriptor.PropertyType;
            var typeCode     = this._typeCodeExtractor.GetTypeCode(propertyType);

            if (typeCode != TypeCode.String)
            {
                yield break;
            }

            var type = "text";
            var fieldCustomAttributes = fieldGenerationContext.FieldDescriptor.CustomAttributes;
            var dataType = _dataTypeAttributeExtractor.GetDataTypeAttribute(fieldCustomAttributes);

            if (dataType != null)
            {
                type = this._stringPropertyTypeMap.MapDataType(dataType.DataType);
            }

            yield return(KeyValuePair.Create("type", (object)type));
        }