コード例 #1
0
        public double GetProperty(RealmPropertyFloat property)
        {
            var att = RealmConverter.PropertyDefinitionsFloat[property];

            if (PropertiesFloat.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);
        }
コード例 #2
0
        public static bool TryRemoveProperty(this Realm realm, RealmPropertyFloat property, out RealmPropertiesFloat entity)
        {
            entity = realm.RealmPropertiesFloat.FirstOrDefault(x => x.Type == (ushort)property);

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

            return(false);
        }
コード例 #3
0
        private static void SetProperty_Complex(Realm realm, RealmPropertyFloat property, RealmPropertyJsonModel pobj)
        {
            var result = realm.RealmPropertiesFloat.FirstOrDefault(x => x.Type == (ushort)property);

            if (result != null)
            {
                result.SetProperties(pobj);
            }
            else
            {
                var entity = new RealmPropertiesFloat {
                    RealmId = realm.Id, Type = (ushort)property
                };
                entity.SetProperties(pobj);
                realm.RealmPropertiesFloat.Add(entity);
            }
        }
コード例 #4
0
        public static void SetProperty(this Realm realm, RealmPropertyFloat property, double value)
        {
            var result = realm.RealmPropertiesFloat.FirstOrDefault(x => x.Type == (ushort)property);

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

                realm.RealmPropertiesFloat.Add(entity);
            }
        }
コード例 #5
0
 public static double?GetProperty(this Realm realm, RealmPropertyFloat property)
 {
     return(realm.RealmPropertiesFloat.FirstOrDefault(x => x.Type == (ushort)property)?.Value);
 }
コード例 #6
0
        public static string GetDescription(this RealmPropertyFloat prop)
        {
            var description = prop.GetAttributeOfType <DescriptionAttribute>();

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