Example #1
0
        public static List <string> GetValues(MetaField metaField, EntityObject metaObject)
        {
            var data = new List <string>();

            if (metaObject == null)
            {
                return(data);
            }

            var value = GetMetaFieldSerializationValue(metaField, metaObject.Properties[metaField.Name]?.Value);

            if (string.IsNullOrEmpty(value))
            {
                return(data);
            }

            data.Add(PropertyValueUtil.ConvertToString(metaField, value));

            return(data);
        }
Example #2
0
        public static string GetMetaFieldSerializationValue(MetaField metaField, object value)
        {
            if (value == null)
            {
                return(null);
            }

            var metaType = metaField.GetMetaType();

            if (metaType.McDataType != McDataType.Enum)
            {
                return(PropertyValueUtil.ConvertToString(metaField, value));
            }

            if (value is MetaEnumItem enumSingleValue)
            {
                return(enumSingleValue.Name);
            }

            return(!(value is MetaEnumItem[] enumMultiValue)
                ? null
                : string.Join("|", enumMultiValue.Select(item => item.Name)));
        }