/// <summary> /// 題型項目選擇事件 /// </summary> /// <param name="isChecked">是否選擇</param> /// <param name="expression">用以獲取控件基本信息對象</param> /// <exception cref="ArgumentNullException"><paramref name="expression"/>為NULL的情況</exception> public void TopicCheckedChanged(bool isChecked, Expression <Func <ControlInfo> > expression) { Guard.ArgumentNotNull(expression, "expression"); ControlInfo info = expression.Compile()(); if (isChecked) { // 題型預覽添加 SetLayoutSettingPreviewList(info.Preview); // 取得HTML和JS的替換內容 ConcurrentDictionary <SubstituteType, string> htmlMaps = GetHtmlReplaceContentMaps(info.Preview); // 按照題型將所有替換內容裝箱子 _htmlMaps.Add(info.ControlId, htmlMaps); } else { // 題型預覽移除 LayoutSettingPreviewList.Remove(info.Preview); // 題型移除 _htmlMaps.Remove(info.ControlId); // 釋放部件資源 MakeHtml.ReleaseExportsHtmlSupport(info.ControlId); PolicyHelper.Instance.ReleaseTopic(info.ControlId); } }
/// <summary> /// 取得HTML和JS的替換內容 /// </summary> /// <param name="topicIdentifier">題型種類</param> /// <returns>替換內容</returns> private ConcurrentDictionary <SubstituteType, string> GetHtmlReplaceContentMaps(string topicIdentifier) { // 題型編號取得 string identifier = TopicManagementList.Where(d => topicIdentifier.Equals(d.TopicIdentifier, StringComparison.CurrentCultureIgnoreCase)).First().Number; // 構造題型并取得結果 TopicParameterBase parameter = PolicyHelper.Instance.Structure(topicIdentifier, identifier); // 題型HTML信息作成并對指定的HTML模板標識進行替換 ConcurrentDictionary <SubstituteType, string> htmlMaps = MakeHtml.GetHtmlReplaceTagDict(topicIdentifier, parameter); return(htmlMaps); }