<commit_before>﻿using System;
using System.Collections.Generic;
using System.Web.UI;

namespace Zongsoft.Web.Controls
{
	public static class FormExtension
	{
		#region 常量定义
		private const string DATACONTEXT_KEY = "__Zongsoft.Web.Controls.DataContext__";
		#endregion

		#region 扩展方法
		public static object GetDataContext(this Page page)
		{
			var stack = GetDataContainer(page);

			if(stack != null && stack.Count > 0)
				return stack.Peek();

			return null;
		}
		#endregion

		#region 公共方法<commit_msg>调整扩展方法的扩展类型，使其可在用户控件(.ascx)中使用。 :stew: :boat:<commit_after>﻿using System;
using System.Collections.Generic;
using System.Web.UI;

namespace Zongsoft.Web.Controls
{
	public static class FormExtension
	{
		#region 常量定义
		private const string DATACONTEXT_KEY = "__Zongsoft.Web.Controls.DataContext__";
		#endregion

		#region 扩展方法
		public static object GetDataContext(this TemplateControl container)
		{
			if(container == null)
				throw new ArgumentNullException("container");

			var page = (container as Page) ?? container.Page;
			var stack = GetDataContainer(page);

			if(stack != null && stack.Count > 0)
				return stack.Peek();

			return null;
		}
		#endregion

		#region 公共方法
{'fraction_non_alphanumeric': 0.10142497904442582, 'fraction_numerical': 0.0016764459346186086, 'mean_word_length': 4.2368421052631575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2739820', 'n_tokens_mistral': 460, 'n_tokens_neox': 417, 'n_words': 96}