Esempio n. 1
0
        /// <summary>
        /// Converts the value to a persistend value.
        /// </summary>
        /// <param name="clrValue">The color value.</param>
        /// <param name="mappings">The mappings.</param>
        /// <param name="tag">The tag.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="FormatException"></exception>
        public static object ToPersistent(object clrValue, TypeMappings mappings, out object tag)
        {
            if (clrValue == null)
            {
                tag = null;
                return(null);
            }

            var clrType       = clrValue.GetType();
            var persistedType = mappings.GetPersisted(clrType);

            if (persistedType == null)
            {
                throw new ArgumentException($"CLR type {clrType.FullName} is not supported");
            }
            tag = persistedType.Tag;
            return(Transtype(clrValue, persistedType.Persisted));
        }
Esempio n. 2
0
 /// <summary>
 /// Converts the value to a persistend value.
 /// </summary>
 /// <param name="clrValue">The color value.</param>
 /// <param name="mappings">The mappings.</param>
 /// <returns></returns>
 /// <exception cref="ArgumentException"></exception>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="FormatException"></exception>
 public static object ToPersistent(object clrValue, TypeMappings mappings) => ToPersistent(clrValue, mappings, out var _);