Пример #1
0
        public void setString(string key, string value)
        {
            C_Property property = db.C_Properties.Find(key);

            if (property == null)
            {
                property = new C_Property { Key = key, Type = PropertyTypes.STRING, Value = value };
                db.C_Properties.Add(property);
            }
            else
            {
                if (isString(property))
                {
                    property.Value = value;
                }
            }
            db.SaveChanges();
        }
Пример #2
0
        public void setBool(string key, bool value)
        {
            C_Property property = db.C_Properties.Find(key);

            if(property == null)
            {
                property = new C_Property { Key = key, Type = PropertyTypes.BOOL, Value = value.ToString() };
                db.C_Properties.Add(property);
            }
            else
            {
                if (isBool(property))
                {
                    property.Value = value.ToString();
                }
            }
            db.SaveChanges();
        }
Пример #3
0
        public void setInt(string key, int value)
        {
            C_Property property = db.C_Properties.Find(key);

            if (property == null)
            {
                property = new C_Property { Key = key, Type = PropertyTypes.INT, Value = value.ToString() };
                db.C_Properties.Add(property);
            }
            else
            {
                if (isInt(property))
                {
                    property.Value = value.ToString(); ;
                }
            }
            db.SaveChanges();
        }
Пример #4
0
 private bool isInt(C_Property property)
 {
     if (property.Type == PropertyTypes.INT)
     {
         return true;
     }
     else
     {
         throw new Exception("Property " + property.Key + " is not a integer");
     }
 }
Пример #5
0
 private bool isString(C_Property property)
 {
     if (property.Type == PropertyTypes.STRING)
     {
         return true;
     }
     else
     {
         throw new Exception("Property " + property.Key + " is not a string");
     }
 }
Пример #6
0
 private bool isBool(C_Property property)
 {
     if (property.Type == PropertyTypes.BOOL)
     {
         return true;
     }
     else
     {
         throw new Exception("Property " + property.Key + " is not a boolean");
     }
 }