public Dictionary <object, object> ConvertToFieldObject(object target)
        {
            var targetType = target.GetType();

            if (targetType != null && _type != targetType)
            {
                return(ObjectProvider.GetDocumentInfo(targetType).ConvertToFieldObject(target));
            }

            var ret = new Dictionary <object, object>();

            foreach (var fieldInfo in DocumentFieldInfos.Values)
            {
                if (!fieldInfo.IsId && !fieldInfo.IsIgnored)
                {
                    var value = fieldInfo.GetValue(target);

                    if (fieldInfo.IsServerTimestampValue(value))
                    {
                        ret[fieldInfo.Name] = Firebase.CloudFirestore.FieldValue.ServerTimestamp;
                    }
                    else
                    {
                        ret[fieldInfo.Name] = value.ToNativeFieldValue(fieldInfo);
                    }
                }
            }

            return(ret);
        }
        public object ConvertToFieldValue(object target)
        {
            var targetType = target.GetType();

            if (targetType != null && _type != targetType)
            {
                return(ObjectProvider.GetDocumentInfo(targetType).ConvertToFieldValue(target));
            }

            var ret = new NSMutableDictionary();

            foreach (var fieldInfo in DocumentFieldInfos.Values)
            {
                if (!fieldInfo.IsId && !fieldInfo.IsIgnored)
                {
                    var value = fieldInfo.GetValue(target);
                    var key   = new NSString(fieldInfo.Name);

                    if (fieldInfo.IsServerTimestampValue(value))
                    {
                        ret[key] = Firebase.CloudFirestore.FieldValue.ServerTimestamp;
                    }
                    else
                    {
                        ret[key] = (NSObject)value.ToNativeFieldValue(fieldInfo);
                    }
                }
            }

            return(ret);
        }
        public object ConvertToFieldValue(object target)
        {
            var targetType = target.GetType();

            if (targetType != null && _type != targetType)
            {
                return(ObjectProvider.GetDocumentInfo(targetType).ConvertToFieldValue(target));
            }
            return(Convert(target));
        }
        public JavaDictionary <string, Java.Lang.Object?> ConvertToFieldObject(object target)
        {
            var targetType = target.GetType();

            if (targetType != null && _type != targetType)
            {
                return(ObjectProvider.GetDocumentInfo(targetType).ConvertToFieldObject(target));
            }
            return(Convert(target));
        }
        public object ConvertToFieldValue(object target)
        {
#if NETSTANDARD
            throw new NotImplementedException();
#else
            var targetType = target.GetType();
            if (targetType != null && _type != targetType)
            {
                return(ObjectProvider.GetDocumentInfo(targetType).ConvertToFieldValue(target));
            }
            return(PlatformConvertToFieldValue(target));
#endif
        }
        private object?PlatformCreate(object?value, ServerTimestampBehavior?serverTimestampBehavior)
        {
            IDocumentInfo documentInfo = _objectDocumentInfo;

            if (value is JavaList || value is AbstractList)
            {
                documentInfo = _listDocumentInfo ?? ObjectProvider.GetDocumentInfo <List <object> >();
            }
            else if ((value is JavaDictionary || value is AbstractMap) && _type == typeof(object))
            {
                documentInfo = ObjectProvider.GetDocumentInfo <Dictionary <string, object> >();
            }
            return(documentInfo.Create(value, serverTimestampBehavior));
        }
        public object?Create(object?value, ServerTimestampBehavior?serverTimestampBehavior)
        {
            IDocumentInfo documentInfo = _objectDocumentInfo;

            if (value is NSArray)
            {
                documentInfo = _listDocumentInfo ?? ObjectProvider.GetDocumentInfo <List <object> >();
            }
            else if (value is NSDictionary && _type == typeof(object))
            {
                documentInfo = ObjectProvider.GetDocumentInfo <Dictionary <string, object> >();
            }
            return(documentInfo.Create(value, serverTimestampBehavior));
        }
Exemplo n.º 8
0
 public static T Map <T>(DocumentSnapshot source, ServerTimestampBehavior?serverTimestampBehavior = null)
 {
     return((T)ObjectProvider.GetDocumentInfo <T>().Create(source, serverTimestampBehavior));
 }
Exemplo n.º 9
0
 public static string GetMappingName(Type type, string name)
 {
     return(ObjectProvider.GetDocumentInfo(type).GetMappingName(name));
 }
Exemplo n.º 10
0
 public static string GetMappingName <T>(string name)
 {
     return(ObjectProvider.GetDocumentInfo <T>().GetMappingName(name));
 }