Example #1
0
        private RealmObject FindByPKGeneric(Type type, object primaryKeyValue, bool isIntegerPK)
        {
            var genericArgument = isIntegerPK ? typeof(long?) : typeof(string);
            var genericMethod   = _realm.GetType().GetMethod(nameof(Realm.Find), new[] { genericArgument });

            object castPKValue;

            if (isIntegerPK)
            {
                if (primaryKeyValue == null)
                {
                    castPKValue = (long?)null;
                }
                else
                {
                    castPKValue = Convert.ToInt64(primaryKeyValue);
                }
            }
            else
            {
                castPKValue = (string)primaryKeyValue;
            }

            return((RealmObject)genericMethod.MakeGenericMethod(type).Invoke(_realm, new[] { castPKValue }));
        }
Example #2
0
        public void CanConvert_checkForRealm_expectTrue()
        {
            RealmConverter realmConverter = new RealmConverter();
            Realm          realm          = new Realm("realm");

            Assert.True(realmConverter.CanConvert(realm.GetType()));
        }
Example #3
0
        internal static Expansion GetRealmExpansion(this Realm val)
        {
            ExpansionAttribute[] attributes = (ExpansionAttribute[])val
                                              .GetType()
                                              .GetField(val.ToString())
                                              .GetCustomAttributes(typeof(ExpansionAttribute), false);

            return(attributes.Length > 0 ? attributes[0].Expansion : Expansion.Undefined);
        }