Example #1
0
        public MobeelizerJsonEntity GetJsonEntity(MobeelizerModelMetadata metadata, MobeelizerDatabaseContext db)
        {
            MobeelizerJsonEntity entity = new MobeelizerJsonEntity();

            entity.Model  = metadata.Model;
            entity.Guid   = metadata.Guid;
            entity.Fields = new Dictionary <string, string>();
            var result = from MobeelizerWp7Model model in db.GetTable(this.Type) where model.Guid == metadata.Guid select model;
            MobeelizerWp7Model modelObject = result.Single();

            entity.Owner = modelObject.Owner;
            entity.Fields.Add("s_deleted", modelObject.Deleted.ToString().ToLower());
            foreach (MobeelizerField field in this.Fields)
            {
                object       value    = null;
                PropertyInfo property = modelObject.GetType().GetProperty(field.Accessor.Name);
                if (property == null)
                {
                    throw new ConfigurationException("There is no property " + field.Accessor.Name + " in " + entity.Model + " class.");
                }

                value = property.GetValue(modelObject, null);
                entity.Fields.Add(field.Name, field.FieldType.SetValueFromDatabaseToMap(value));
            }

            return(entity);
        }
Example #2
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));
            }
        }
Example #3
0
        internal bool ValidateEntity(MobeelizerWp7Model insert, MobeelizerErrorsHolder errors)
        {
            String model = insert.GetType().Name;

            return(models[model].Validate(insert, errors));
        }