示例#1
0
 public static Data ToData(object @object,
                           ObjectDataConvertSettings settings = null, ObjectDataConvertSession session = null)
 {
     if (ValueData.TryCreate(@object, out var valueData))
     {
         return(valueData);
     }
     return(ObjectDataConverter.ToData(null, @object, settings, session));
 }
示例#2
0
        public ObjectData ToData(object @object,
                                 ObjectDataConvertSettings settings = null, ObjectDataConvertSession session = null)
        {
            if (ValueData.CanCreate(@object))
            {
                throw new ArgumentException($"Object can be only converted to {typeof(ValueData)}", nameof(@object));
            }

            return(ToData(this, @object, settings, session));
        }
示例#3
0
        public bool AddConverted(object @object, ObjectData data)
        {
            Ensure.Argument.NotNull(@object, nameof(@object));

            if (ValueData.CanCreate(@object))
            {
                return(false);
            }

            return(_objectToData.TryAdd(@object, data) ||
                   _dataToObject.TryAdd(data, @object));
        }