public int GetProperty(RealmPropertyInt property) { var att = RealmConverter.PropertyDefinitionsInt[property]; if (PropertiesInt.TryGetValue(property, out var result)) { var val = result.Value; val = Math.Max(val, att.MinValue); val = Math.Min(val, att.MaxValue); return(val); } return(att.DefaultValue); }
public static bool TryRemoveProperty(this Realm realm, RealmPropertyInt property, out RealmPropertiesInt entity) { entity = realm.RealmPropertiesInt.FirstOrDefault(x => x.Type == (uint)property); if (entity != null) { realm.RealmPropertiesInt.Remove(entity); entity.Realm = null; return(true); } return(false); }
private static void SetProperty_Complex(Realm realm, RealmPropertyInt property, RealmPropertyJsonModel pobj) { var result = realm.RealmPropertiesInt.FirstOrDefault(x => x.Type == (ushort)property); if (result != null) { result.SetProperties(pobj); } else { var entity = new RealmPropertiesInt { RealmId = realm.Id, Type = (ushort)property }; entity.SetProperties(pobj); realm.RealmPropertiesInt.Add(entity); } }
public static void SetProperty(this Realm realm, RealmPropertyInt property, int value) { var result = realm.RealmPropertiesInt.FirstOrDefault(x => x.Type == (uint)property); if (result != null) { result.Value = value; } else { var entity = new RealmPropertiesInt { RealmId = realm.Id, Type = (ushort)property, Value = value, Realm = realm }; realm.RealmPropertiesInt.Add(entity); } }
public static string GetDescription(this RealmPropertyInt prop) { var description = prop.GetAttributeOfType <DescriptionAttribute>(); return(description?.Description ?? prop.ToString()); }
public static int?GetProperty(this Realm realm, RealmPropertyInt property) { return(realm.RealmPropertiesInt.FirstOrDefault(x => x.Type == (uint)property)?.Value); }