コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public object ConvertToFieldValue(object target)
        {
            var targetType = target.GetType();

            if (targetType != null && _type != targetType)
            {
                return(ObjectProvider.GetDocumentInfo(targetType).ConvertToFieldValue(target));
            }
            return(Convert(target));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
 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));
 }
コード例 #6
0
        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
        }
コード例 #7
0
 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));
 }
コード例 #8
0
        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));
        }
コード例 #9
0
        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));
        }
コード例 #10
0
 public static T Map <T>(DocumentSnapshot source, ServerTimestampBehavior?serverTimestampBehavior = null)
 {
     return((T)ObjectProvider.GetDocumentInfo <T>().Create(source, serverTimestampBehavior));
 }
コード例 #11
0
 public static string GetMappingName(Type type, string name)
 {
     return(ObjectProvider.GetDocumentInfo(type).GetMappingName(name));
 }
コード例 #12
0
 public static string GetMappingName <T>(string name)
 {
     return(ObjectProvider.GetDocumentInfo <T>().GetMappingName(name));
 }