/// <summary> /// Given a type, get the default form for it. /// </summary> /// <param name="entityType">Type of the entity.</param> /// <param name="isInDesignMode">if set to <c>true</c> [is in design mode].</param> /// <param name="forceGenerate">Force a generated form to be used</param> /// <returns> /// A response containing entity data for the form /// </returns> public static HttpResponseMessage <JsonQueryResult> GetDefaultFormForType(EntityType entityType, bool isInDesignMode, bool forceGenerate) { CustomEditForm formRef = entityType.DefaultEditForm; if (formRef != null && !forceGenerate) { var entityBatch = new EntityPackage( ); EntityData formEntityData = EditFormHelper.GetFormAsEntityData(formRef); entityBatch.AddEntityData(formEntityData, "formEntity"); return(new HttpResponseMessage <JsonQueryResult>(entityBatch.GetQueryResult( ))); } //TODO: return something to indicate that there is no form return(GetGeneratedFormForType(entityType, isInDesignMode)); }
/// <summary> /// Gets the form as entity data. /// </summary> /// <param name="formId">The form identifier.</param> /// <param name="isInDesignMode">if set to <c>true</c> [is in design mode].</param> /// <returns></returns> public EntityData GetFormAsEntityData(long formId, bool isInDesignMode) { EntityData formEntityData; _formsCache.TryGetOrAdd(formId, out formEntityData, key => { var formEntity = EditFormHelper.GetFormAsEntityData(key, isInDesignMode); if (formEntity == null) { throw new Exception("entityData was null"); } return(formEntity); }); return(formEntityData); }
public void Test_GetForm_DesignMode() { EntityData form = EditFormHelper.GetFormAsEntityData("console:resourceInfoEditForm", true); Assert.IsNotNull(form); }