Beispiel #1
0
 private void UpdateEntity(MobeelizerDatabaseContext db, MobeelizerModelMetadata metadate, IDictionary<String, object> values, String guid, MobeelizerWp7Model entity)
 {
     foreach (KeyValuePair<String, object> value in values)
     {
         if (value.Key == "Conflicted" || value.Key == "Deleted" || value.Key == "Modified")
         {
             PropertyInfo property = this.Type.GetProperty(value.Key);
             property.SetValue(entity, ((Int32)value.Value == 1) ? true : false, null);
         }
         else
         {
             PropertyInfo property = this.Type.GetProperty(value.Key);
             property.SetValue(entity, value.Value, null);
         }
     }
     Log.i("mobeelizermodel", "Upadate entity from sync " + metadate.Model + ", guid: " + metadate.Guid);
 }
Beispiel #2
0
        internal bool Validate(MobeelizerWp7Model insert, MobeelizerErrorsHolder errors)
        {
            Dictionary<String, object> values = new Dictionary<string, object>();
            MapEntityToDictionary(insert, values);
            foreach (MobeelizerField field in this.Fields)
            {
                field.Validate(values, errors);
            }

            if (!errors.IsValid)
            {
                return false;
            }

            return true;
        }
Beispiel #3
0
 private void MapEntityToDictionary(MobeelizerWp7Model model, Dictionary<String, object> values)
 {
     Type type = model.GetType();
     foreach (var filed in Fields)
     {
         PropertyInfo info = type.GetProperty(filed.Accessor.Name);
         values.Add(info.Name, info.GetValue(model,null));
     }
 }
 internal bool ValidateEntity(MobeelizerWp7Model insert, MobeelizerErrorsHolder errors)
 {
     String model = insert.GetType().Name;
     return models[model].Validate(insert, errors);
 }