public EditingSession EditingSession(CmsForm form, WarpCoreEntity entity) { var editingScope = BuildObjectEditingScope(form); var initialValues = entity.GetPropertyValues(x => editingScope.Contains(x.Name)); return(EditingSession(form, entity.GetType(), initialValues)); }
public static WarpCoreEntityAttribute GetEntityAttribute(this WarpCoreEntity entity) { var entityType = entity.GetType(); var atr = (WarpCoreEntityAttribute)entityType.GetCustomAttribute(typeof(WarpCoreEntityAttribute)); return(atr); }
public void Delete(WarpCoreEntity copy) { var tableRef = GetOrCreateTable(copy.GetType()); DataRow dr = tableRef.Select("RowKey = '" + copy.RowKey + "'").SingleOrDefault(); if (dr != null) { tableRef.Rows.Remove(dr); } }
public void Save(WarpCoreEntity item) { if (!item.IsDirty) { return; } var tableRef = GetOrCreateTable(item.GetType()); DataRow dr = null; if (item.RowKey != null) { dr = tableRef.Select("RowKey = '" + item.RowKey + "'").SingleOrDefault(); } bool isNew = dr == null; if (isNew) { dr = tableRef.NewRow(); item.RowKey = Guid.NewGuid().ToString(); if (item.ContentId == Guid.Empty) { item.ContentId = Guid.NewGuid(); } } dr["RowKey"] = new Guid(item.RowKey); dr["PartitionKey"] = item.PartitionKey; var readProperties = item.GetType().GetProperties().Where(x => !ShouldSkipProperty(x) && x.GetCustomAttribute <SerializedComplexObjectAttribute>() == null); foreach (var prop in readProperties) { dr[prop.Name] = prop.GetValue(item) ?? DBNull.Value; } dr["ComplexData"] = item.ComplexData; if (isNew) { tableRef.Rows.Add(dr); } }