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)); }
private IDictionaryAdapter GetDictionaryAdapter(object target) { if (_dictionaryAdapterFactory == null) { _dictionaryAdapterFactory = _dictionaryAdapterFactoryType switch { DictionaryAdapterFactoryType.Generic => ObjectProvider.GetDictionaryAdapterFactory(_dictionaryKeyType, _dictionaryValueType), DictionaryAdapterFactoryType.NonGeneric => ObjectProvider.GetDictionaryAdapterFactory(), _ => throw new InvalidOperationException(), }; } return(_dictionaryAdapterFactory.Create(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 IListAdapter GetListAdapter(object target) { if (_listAdapterFactory == null) { _listAdapterFactory = _listAdapterFactoryType switch { ListAdapterFactoryType.Generic => ObjectProvider.GetListAdapterFactory(_listValueType), ListAdapterFactoryType.NonGeneric => ObjectProvider.GetListAdapterFactory(), _ => throw new InvalidOperationException(), }; } return(_listAdapterFactory.Create(target)); }
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)); }
public static T Map <T>(DocumentSnapshot source, ServerTimestampBehavior?serverTimestampBehavior = null) { return((T)ObjectProvider.GetDocumentInfo <T>().Create(source, serverTimestampBehavior)); }
public static string GetMappingName(Type type, string name) { return(ObjectProvider.GetDocumentInfo(type).GetMappingName(name)); }
public static string GetMappingName <T>(string name) { return(ObjectProvider.GetDocumentInfo <T>().GetMappingName(name)); }