public bool GetProperty(RealmPropertyBool property)
 {
     if (PropertiesBool.TryGetValue(property, out var value))
     {
         return(value.Value);
     }
     return(RealmConverter.PropertyDefinitionsBool[property].DefaultValue);
 }
        // =====================================
        // Remove
        // Bool, DID, Float, Int, Int64, String
        // =====================================

        public static bool TryRemoveProperty(this Realm realm, RealmPropertyBool property, out RealmPropertiesBool entity)
        {
            entity = realm.RealmPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (entity != null)
            {
                realm.RealmPropertiesBool.Remove(entity);
                entity.Realm = null;
                return(true);
            }

            return(false);
        }
        private static void SetProperty_Complex(Realm realm, RealmPropertyBool property, RealmPropertyJsonModel pobj)
        {
            var result = realm.RealmPropertiesBool.FirstOrDefault(x => x.Type == (ushort)property);

            if (result != null)
            {
                result.SetProperties(pobj);
            }
            else
            {
                var entity = new RealmPropertiesBool {
                    RealmId = realm.Id, Type = (ushort)property
                };
                entity.SetProperties(pobj);
                realm.RealmPropertiesBool.Add(entity);
            }
        }
        public static void SetProperty(this Realm realm, RealmPropertyBool property, bool value)
        {
            var result = realm.RealmPropertiesBool.FirstOrDefault(x => x.Type == (uint)property);

            if (result != null)
            {
                result.Value = value;
            }
            else
            {
                var entity = new RealmPropertiesBool {
                    RealmId = realm.Id, Type = (ushort)property, Value = value, Realm = realm
                };

                realm.RealmPropertiesBool.Add(entity);
            }
        }
        // =====================================
        // Get
        // Bool, DID, Float, Int, Int64, String
        // =====================================

        public static bool?GetProperty(this Realm realm, RealmPropertyBool property)
        {
            return(realm.RealmPropertiesBool.FirstOrDefault(x => x.Type == (uint)property)?.Value);
        }
Beispiel #6
0
        public static string GetDescription(this RealmPropertyBool prop)
        {
            var description = prop.GetAttributeOfType <DescriptionAttribute>();

            return(description?.Description ?? prop.ToString());
        }