大佬教程收集整理的这篇文章主要介绍了asp.net – 来自web.config的Asp .Net自定义成员资格参数,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
public override void Initialize(String name,NameValueCollection config);
System.Collections.NameValueCollection是一个字典,您可以在其中找到web.config文件中编写的选项.这些选项的指定方式与指定“标准”提供程序的选项(作为属性)的方式相同.每个字典条目都具有属性名称的键,并且具有属性值(作为字符串)的值.
public class MymembershipProvider : MembershipProvider { public override void Initialize(String name,NameValueCollection config) { base.Initialize(name,config); _enablepasswordReset = config.GetBoolean("enablepasswordReset",truE); } }
在我的例子中,GetBoolean()是一个在下面声明的扩展方法:
public static bool GetBoolean(this NameValueCollection config,String valuename,bool? DefaultValuE) { object obj = config[valuename]; if (obj == null) { if (!DefaultValue.Hasvalue) throw new WarningException("required field has not been specified."); return DefaultValue.Value; } bool value = DefaultValue; if (obj is Boolean) return (bool)obj; IConvertible convertible = obj as IConvertible; try { return convertible.ToBoolean(CultureInfo.InvariantCulturE); } catch (Exception) { if (!DefaultValue.Hasvalue) throw new WarningException("required field has invalid format."); return DefaultValue.Value; } }
以上是大佬教程为你收集整理的asp.net – 来自web.config的Asp .Net自定义成员资格参数全部内容,希望文章能够帮你解决asp.net – 来自web.config的Asp .Net自定义成员资格参数所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。