⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 providersettingsvalidation.cs

📁 详细介绍中小企业的网站编程,附有详细的注释,对需要制作网站的朋友有很大的帮助,有需要的朋友可下载,
💻 CS
字号:
using System;
using System.Configuration;


/// <summary>
// ensures the providerCollection contains a set of ProviderSettings, where each one
// "is a " Provider
/// </summary>
public class ProviderSettingsValidation : ConfigurationValidatorBase {

    public override bool CanValidate(Type type) 
    {
      return type == typeof(ProviderSettingsCollection);
    }

    /// <summary>
    // validate the provider section    
    /// </summary>
    public override void Validate(object value) 
    {
      ProviderSettingsCollection providerCollection = value as ProviderSettingsCollection;
      if (providerCollection != null) 
      {

        foreach (ProviderSettings _provider in providerCollection) 
        {
          if (String.IsNullOrEmpty(_provider.Type)) 
          {
            throw new ConfigurationErrorsException("Type was not defined in the provider");
          }

          Type dataAccessType = Type.GetType(_provider.Type);
          if (dataAccessType == null) 
          {
              throw (new InvalidOperationException("Provider's Type could not be found"));
          }
        }
      }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -