示例#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);
 }
示例#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;
        }
示例#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));
     }
 }
示例#4
0
 internal bool ValidateEntity(MobeelizerWp7Model insert, MobeelizerErrorsHolder errors)
 {
     String model = insert.GetType().Name;
     return models[model].Validate(insert, errors);
 }