Stack() public method

public Stack ( System.Action callback ) : void
callback System.Action
return void
Exemplo n.º 1
0
		/// <summary>
		/// 描画内容
		/// </summary>
		/// <param name="context"></param>
		/// <param name="result"></param>
		public override void Render(Context context, TextWriter result) {
			// 获取所在区域,没有区域时抛例外
			if (context[Area.CurrentAreaIdKey] == null) {
				throw new FormatException("widget must use inside area");
			}
			// 获取模块名称和参数
			var markup = this.Markup.Trim();
			string widgetPath = null;
			string widgetArgs = null;
			var index = markup.IndexOf(' ');
			if (index > 0) {
				widgetPath = markup.Substring(0, index);
				widgetArgs = markup.Substring(index + 1);
			} else {
				widgetPath = markup;
			}
			// 添加div的开头
			result.Write($"<div class='diy_widget' path='{widgetPath}' args='{widgetArgs}' >");
			// 描画模块的内容
			var scope = widgetArgs == null ? new Hash() : Hash.FromDictionary(
				JsonConvert.DeserializeObject<IDictionary<string, object>>(widgetArgs));
			context.Stack(scope, () => {
				var includeTag = new Include();
				var htmlPath = widgetPath + DiyWidgetInfo.HtmlExtension;
				includeTag.Initialize("include", htmlPath, null);
				includeTag.Render(context, result);
			});
			// 添加div的末尾
			result.Write("</div>");
		}
Exemplo n.º 2
0
		/// <summary>
		/// 描画标签
		/// </summary>
		/// <param name="context"></param>
		/// <param name="result"></param>
		public override void Render(Context context, TextWriter result) {
			var areaId = this.Markup.Trim();
			// 区域不能嵌套
			if (context[CurrentAreaIdKey] != null) {
				throw new FormatException("area tag can't be nested");
			}
			// 添加div的开头
			result.Write($"<div class='diy_area' area_id='{areaId}' >");
			// 描画子元素
			var scope = Hash.FromDictionary(new Dictionary<string, object>() {
				{ CurrentAreaIdKey, areaId }
			});
			context.Stack(scope, () => RenderAll(NodeList, context, result));
			// 添加div的末尾
			result.Write("</div>");
		}
Exemplo n.º 3
0
 public override void Render(Context context, TextWriter result)
 {
     context.Stack(() => { context.Registers["current_page"] = this._page; });
 }