zoukankan      html  css  js  c++  java
  • 代码

    using System;
    using System.Collections;
    using System.Security.Cryptography;
    using System.Text;
    using System.Web;
    using System.IO;

    using System.Collections.Specialized;

    using System.Web.Caching;
    using System.Xml;
    using System.Configuration;
    using System.Xml.Serialization;


    namespace Utility
    {
     /// <summary>
     /// Common 的摘要说明。
     /// </summary>
     public class Common
     {
      #region 成员字段
      public static readonly string CacheKey = "ForumsConfiguration";
      private Hashtable providers = new Hashtable();
      private Hashtable extensions = new Hashtable();
      private static readonly Cache cache = HttpRuntime.Cache;
      private string defaultProvider;
      private string defaultLanguage;
      private string forumFilesPath;
      private bool disableBackgroundThreads = false;
      private bool disableIndexing = false;
      private bool disableEmail = false;
      private string passwordEncodingFormat = "unicode";
      private int threadIntervalEmail = 15;
      private int threadIntervalStats = 15;
      //private SystemType systemType = SystemType.Self;
      private short smtpServerConnectionLimit = -1;
      private bool enableLatestVersionCheck = true;
      private string uploadFilesPath = "/Upload/";
      private XmlDocument XmlDoc = null;
      #endregion
      public Common()
      {
       //
       // TODO: 在此处添加构造函数逻辑
       //
      }
      public enum UserPasswordFormat
      {
       ClearText = 0,
       MD5Hash = 1,
       Sha1Hash = 2,
       Encyrpted = 3
      }
      public string PasswordEncodingFormat
      {
       get { return passwordEncodingFormat; }
      }
      public static string Encrypt(UserPasswordFormat format, string cleanString, string salt)
      {
       Byte[] clearBytes;
       Byte[] hashedBytes;
       Encoding encoding = Encoding.GetEncoding("unicode");
       clearBytes = encoding.GetBytes(salt.ToLower().Trim() + cleanString.Trim());

       hashedBytes = ((HashAlgorithm) CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);

         return BitConverter.ToString(hashedBytes);
         ;                     
       
      }
      public static Common GetConfig()
      {
       Common config = cache.Get(CacheKey) as Common;
       if(config == null)
       {
        string path;
        if(HttpContext.Current != null)
         path = HttpContext.Current.Server.MapPath("~/Forums.config");
        else
         path = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar + "Forums.config";

        XmlDocument doc = new XmlDocument();
        doc.Load(path);
        config = new Common(doc);
        cache.Insert(CacheKey,config,new CacheDependency(path),DateTime.MaxValue,TimeSpan.Zero,CacheItemPriority.AboveNormal,null);

        //cache.ReSetFactor(config.CacheFactor);
       }
       return config;
               
      }
     }
    }

  • 相关阅读:
    C语言实现数据结构中的顺序栈
    什么是A股什么是B股,为什么有AB股之分?
    C语言实现数据结构中的链队列
    C语言实现数据结构中的循环链表
    C语言实现数据结构的链表
    C语言中指针变量作为函数参数和一般变量作为函数参数的区别
    javascrip实现下拉框联动
    C语言实现数据结构中的顺序表
    C语言实现数据结构中的链栈
    SQL语句之基础增删改查 time
  • 原文地址:https://www.cnblogs.com/sujingnan/p/963743.html
Copyright © 2011-2022 走看看