private static string CreateFieldString(this IXmlFieldInfoDescriptor fieldDescriptor, object fieldValue)
        {
            if (fieldDescriptor.Converter == null)
            {
                if (fieldValue == null)
                {
                    return(string.Empty);
                }
                return(fieldValue.ToString());
            }

            ConverterBase converterInstance =
                ConverterFactory.GetConverter(fieldDescriptor.Converter, fieldDescriptor.ConverterFormat);

            return(converterInstance?.FieldToString(fieldValue) ?? string.Empty);
        }
Exemplo n.º 2
0
        public static string CreateFieldString(this IFieldInfoDescriptor fieldBuilder, object fieldValue)
        {
            ConverterBase converterInstance = null;

            if (fieldBuilder.Type != null || fieldBuilder.Converter != null)
            {
                converterInstance = fieldBuilder.Converter == null
                ? ConverterFactory.GetDefaultConverter(fieldBuilder.Type, fieldBuilder.ConverterFormat)
                : ConverterFactory.GetConverter(fieldBuilder.Converter, fieldBuilder.ConverterFormat);
            }

            if (converterInstance == null)
            {
                if (fieldValue == null)
                {
                    return(string.Empty);
                }

                return(fieldValue.ToString());
            }

            return(converterInstance.FieldToString(fieldValue) ?? string.Empty);
        }