亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? converterregistry.cs

?? 網上書店系統
?? CS
字號:
#region Copyright & License
//
// Copyright 2001-2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System;
using System.Globalization;
using System.Reflection;
using System.Collections;

namespace log4net.Util.TypeConverters
{
	/// <summary>
	/// Register of type converters for specific types.
	/// </summary>
	/// <remarks>
	/// <para>
	/// Maintains a registry of type converters used to convert between
	/// types.
	/// </para>
	/// <para>
	/// Use the <see cref="AddConverter(Type, object)"/> and 
	/// <see cref="AddConverter(Type, Type)"/> methods to register new converters.
	/// The <see cref="GetConvertTo"/> and <see cref="GetConvertFrom"/> methods
	/// lookup appropriate converters to use.
	/// </para>
	/// </remarks>
	/// <seealso cref="IConvertFrom"/>
	/// <seealso cref="IConvertTo"/>
	/// <author>Nicko Cadell</author>
	/// <author>Gert Driesen</author>
	public sealed class ConverterRegistry
	{
		#region Private Constructors

		/// <summary>
		/// Private constructor
		/// </summary>
		/// <remarks>
		/// Initializes a new instance of the <see cref="ConverterRegistry" /> class.
		/// </remarks>
		private ConverterRegistry() 
		{
		}

		#endregion Private Constructors

		#region Static Constructor

		/// <summary>
		/// Static constructor.
		/// </summary>
		/// <remarks>
		/// <para>
		/// This constructor defines the intrinsic type converters.
		/// </para>
		/// </remarks>
		static ConverterRegistry()
		{
			// Add predefined converters here
			AddConverter(typeof(bool), typeof(BooleanConverter));
			AddConverter(typeof(System.Text.Encoding), typeof(EncodingConverter));
			AddConverter(typeof(System.Type), typeof(TypeConverter));
			AddConverter(typeof(log4net.Layout.PatternLayout), typeof(PatternLayoutConverter));
			AddConverter(typeof(log4net.Util.PatternString), typeof(PatternStringConverter));
			AddConverter(typeof(System.Net.IPAddress), typeof(IPAddressConverter));
		}

		#endregion Static Constructor

		#region Public Static Methods

		/// <summary>
		/// Adds a converter for a specific type.
		/// </summary>
		/// <param name="destinationType">The type being converted to.</param>
		/// <param name="converter">The type converter to use to convert to the destination type.</param>
		/// <remarks>
		/// <para>
		/// Adds a converter instance for a specific type.
		/// </para>
		/// </remarks>
		public static void AddConverter(Type destinationType, object converter)
		{
			if (destinationType != null && converter != null)
			{
				lock(s_type2converter)
				{
					s_type2converter[destinationType] = converter;
				}
			}
		}

		/// <summary>
		/// Adds a converter for a specific type.
		/// </summary>
		/// <param name="destinationType">The type being converted to.</param>
		/// <param name="converterType">The type of the type converter to use to convert to the destination type.</param>
		/// <remarks>
		/// <para>
		/// Adds a converter <see cref="Type"/> for a specific type.
		/// </para>
		/// </remarks>
		public static void AddConverter(Type destinationType, Type converterType)
		{
			AddConverter(destinationType, CreateConverterInstance(converterType));
		}

		/// <summary>
		/// Gets the type converter to use to convert values to the destination type.
		/// </summary>
		/// <param name="sourceType">The type being converted from.</param>
		/// <param name="destinationType">The type being converted to.</param>
		/// <returns>
		/// The type converter instance to use for type conversions or <c>null</c> 
		/// if no type converter is found.
		/// </returns>
		/// <remarks>
		/// <para>
		/// Gets the type converter to use to convert values to the destination type.
		/// </para>
		/// </remarks>
		public static IConvertTo GetConvertTo(Type sourceType, Type destinationType)
		{
			// TODO: Support inheriting type converters.
			// i.e. getting a type converter for a base of sourceType

			// TODO: Is destinationType required? We don't use it for anything.

			lock(s_type2converter)
			{
				// Lookup in the static registry
				IConvertTo converter = s_type2converter[sourceType] as IConvertTo;

				if (converter == null)
				{
					// Lookup using attributes
					converter = GetConverterFromAttribute(sourceType) as IConvertTo;

					if (converter != null)
					{
						// Store in registry
						s_type2converter[sourceType] = converter;
					}
				}

				return converter;
			}
		}

		/// <summary>
		/// Gets the type converter to use to convert values to the destination type.
		/// </summary>
		/// <param name="destinationType">The type being converted to.</param>
		/// <returns>
		/// The type converter instance to use for type conversions or <c>null</c> 
		/// if no type converter is found.
		/// </returns>
		/// <remarks>
		/// <para>
		/// Gets the type converter to use to convert values to the destination type.
		/// </para>
		/// </remarks>
		public static IConvertFrom GetConvertFrom(Type destinationType)
		{
			// TODO: Support inheriting type converters.
			// i.e. getting a type converter for a base of destinationType

			lock(s_type2converter)
			{
				// Lookup in the static registry
				IConvertFrom converter = s_type2converter[destinationType] as IConvertFrom;

				if (converter == null)
				{
					// Lookup using attributes
					converter = GetConverterFromAttribute(destinationType) as IConvertFrom;

					if (converter != null)
					{
						// Store in registry
						s_type2converter[destinationType] = converter;
					}
				}

				return converter;
			}
		}
		
		/// <summary>
		/// Lookups the type converter to use as specified by the attributes on the 
		/// destination type.
		/// </summary>
		/// <param name="destinationType">The type being converted to.</param>
		/// <returns>
		/// The type converter instance to use for type conversions or <c>null</c> 
		/// if no type converter is found.
		/// </returns>
		private static object GetConverterFromAttribute(Type destinationType)
		{
			// Look for an attribute on the destination type
			object[] attributes = destinationType.GetCustomAttributes(typeof(TypeConverterAttribute), true);
			if (attributes != null && attributes.Length > 0)
			{
				TypeConverterAttribute tcAttr = attributes[0] as TypeConverterAttribute;
				if (tcAttr != null)
				{
					Type converterType = SystemInfo.GetTypeFromString(destinationType, tcAttr.ConverterTypeName, false, true);
					return CreateConverterInstance(converterType);
				}
			}

			// Not found converter using attributes
			return null;
		}

		/// <summary>
		/// Creates the instance of the type converter.
		/// </summary>
		/// <param name="converterType">The type of the type converter.</param>
		/// <returns>
		/// The type converter instance to use for type conversions or <c>null</c> 
		/// if no type converter is found.
		/// </returns>
		/// <remarks>
		/// <para>
		/// The type specified for the type converter must implement 
		/// the <see cref="IConvertFrom"/> or <see cref="IConvertTo"/> interfaces 
		/// and must have a public default (no argument) constructor.
		/// </para>
		/// </remarks>
		private static object CreateConverterInstance(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType", "CreateConverterInstance cannot create instance, converterType is null");
			}

			// Check type is a converter
			if (typeof(IConvertFrom).IsAssignableFrom(converterType) || typeof(IConvertTo).IsAssignableFrom(converterType))
			{
				try
				{
					// Create the type converter
					return Activator.CreateInstance(converterType);
				}
				catch(Exception ex)
				{
					LogLog.Error("ConverterRegistry: Cannot CreateConverterInstance of type ["+converterType.FullName+"], Exception in call to Activator.CreateInstance", ex);
				}
			}
			else
			{
				LogLog.Error("ConverterRegistry: Cannot CreateConverterInstance of type ["+converterType.FullName+"], type does not implement IConvertFrom or IConvertTo");
			}
			return null;
		}

		#endregion Public Static Methods

		#region Private Static Fields

		/// <summary>
		/// Mapping from <see cref="Type" /> to type converter.
		/// </summary>
		private static Hashtable s_type2converter = new Hashtable();

		#endregion
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91国产丝袜在线播放| 欧美一级欧美一级在线播放| 亚洲综合色网站| 久久久影视传媒| 欧美日韩二区三区| 99国产精品久| 国产伦精品一区二区三区免费迷 | 欧美日韩亚洲国产综合| 国产在线麻豆精品观看| 亚洲v中文字幕| 亚洲男同性恋视频| 日本一区二区成人| 精品国产一区二区亚洲人成毛片| 在线亚洲一区二区| 成人黄色国产精品网站大全在线免费观看| 亚洲成av人片一区二区梦乃| 亚洲日本va午夜在线电影| 精品对白一区国产伦| 3d动漫精品啪啪1区2区免费| 在线视频国产一区| 99re热这里只有精品免费视频| 加勒比av一区二区| 日本不卡在线视频| 亚洲18女电影在线观看| 亚洲美女视频一区| 中文字幕一区二区5566日韩| 久久综合视频网| 日韩一区二区影院| 91麻豆精品国产| 欧美日韩高清不卡| 欧美巨大另类极品videosbest| 在线中文字幕一区| 在线免费不卡视频| 欧美在线一二三| 在线观看亚洲专区| 欧美三电影在线| 欧美色中文字幕| 欧美天堂亚洲电影院在线播放| 色噜噜久久综合| 色综合久久久久综合体桃花网| 99在线精品一区二区三区| 成人动漫精品一区二区| 粉嫩嫩av羞羞动漫久久久 | 欧美精品一二三| 欧美日韩美少妇| 欧美挠脚心视频网站| 欧美日韩免费高清一区色橹橹 | 久久新电视剧免费观看| 精品国内片67194| 久久你懂得1024| 欧美激情一二三区| 国产精品福利一区| 亚洲精品免费在线观看| 亚洲一区二区欧美日韩| 调教+趴+乳夹+国产+精品| 三级亚洲高清视频| 麻豆精品在线观看| 国产成人啪午夜精品网站男同| 国产麻豆欧美日韩一区| 国产成人h网站| caoporm超碰国产精品| 色婷婷精品久久二区二区蜜臀av| 在线亚洲一区观看| 日韩午夜电影在线观看| 久久久亚洲国产美女国产盗摄| 国产欧美日韩在线观看| 中文字幕综合网| 亚洲成人久久影院| 寂寞少妇一区二区三区| av不卡一区二区三区| 欧美亚洲禁片免费| 日韩精品一区二区三区蜜臀| 欧美国产一区二区| 亚洲综合丁香婷婷六月香| 日韩va欧美va亚洲va久久| 国内偷窥港台综合视频在线播放| 成人免费视频caoporn| 欧美亚洲国产bt| 亚洲精品在线观看网站| 亚洲特黄一级片| 免费观看在线综合色| 国产不卡在线一区| 欧美性受极品xxxx喷水| 久久夜色精品国产欧美乱极品| 日韩毛片在线免费观看| 日本成人中文字幕在线视频 | 91精品国产综合久久精品图片| 精品国产免费一区二区三区香蕉| 中文字幕一区二区三区不卡在线 | 91色porny蝌蚪| 欧美一卡在线观看| 国产精品久久毛片| 日韩av网站在线观看| av电影天堂一区二区在线观看| 日韩欧美国产综合一区| 亚洲人成网站在线| 国产乱码精品一区二区三区忘忧草 | 在线观看网站黄不卡| 久久久青草青青国产亚洲免观| 亚洲国产成人tv| 波波电影院一区二区三区| 91精品国产麻豆| 亚洲欧美日韩一区二区三区在线观看| 免费高清不卡av| 欧洲亚洲国产日韩| 国产精品国产精品国产专区不片| 久久激情五月婷婷| 欧美色电影在线| 国产精品久久久久久久久搜平片| 久色婷婷小香蕉久久| 欧美三电影在线| 亚洲色图视频网站| 国v精品久久久网| 欧美大片国产精品| 亚洲妇女屁股眼交7| 色综合天天综合网国产成人综合天 | 欧洲一区二区三区在线| 国产精品日产欧美久久久久| 久久99久久久欧美国产| 7777精品久久久大香线蕉| 亚洲蜜臀av乱码久久精品| zzijzzij亚洲日本少妇熟睡| 久久久久久久久蜜桃| 精品一区二区在线免费观看| 制服丝袜中文字幕亚洲| 亚洲高清久久久| 欧美日韩美女一区二区| 一区二区高清在线| 色天使色偷偷av一区二区 | 蜜臀久久久久久久| 7777女厕盗摄久久久| 三级一区在线视频先锋| 欧美精品久久99久久在免费线| 亚洲综合视频在线观看| 欧美日韩一级片在线观看| 一区二区在线电影| 欧美亚洲另类激情小说| 亚洲一区二区美女| 777午夜精品视频在线播放| 午夜精品久久久久久久| 在线播放欧美女士性生活| 天堂在线一区二区| 91麻豆精品91久久久久同性| 奇米综合一区二区三区精品视频| 日韩亚洲欧美综合| 久久99精品国产麻豆婷婷| 精品999久久久| 丁香啪啪综合成人亚洲小说| 国产精品嫩草99a| 99视频超级精品| 亚洲一区二区三区中文字幕| 欧美日韩一区二区三区四区五区| 五月婷婷激情综合| 日韩欧美亚洲另类制服综合在线| 国产在线精品视频| 亚洲欧洲成人精品av97| 欧美主播一区二区三区美女| 日韩精品亚洲专区| 久久综合九色综合97婷婷女人 | 天天综合日日夜夜精品| 日韩一级片在线播放| 国产精品99久| 亚洲女女做受ⅹxx高潮| 欧美日韩精品福利| 国内精品伊人久久久久影院对白| 国产欧美一二三区| 欧美三区免费完整视频在线观看| 日本亚洲天堂网| 国产日产精品1区| 色婷婷狠狠综合| 麻豆视频一区二区| 亚洲欧美自拍偷拍色图| 91精品国产综合久久久久久漫画| 国产又粗又猛又爽又黄91精品| 国产精品天干天干在观线| 欧美亚洲综合一区| 国产乱子伦视频一区二区三区| 中文字幕制服丝袜一区二区三区| 欧美日韩国产首页在线观看| 国产在线一区二区| 一区二区三区成人在线视频| 日韩欧美一区在线| 97久久人人超碰| 美女一区二区三区| 亚洲免费观看在线视频| 欧美精品一区二区久久婷婷| 91视频一区二区三区| 久久精品国产精品亚洲精品| 亚洲欧美成人一区二区三区| 欧美精品一区二区在线观看| 在线视频一区二区免费| 国产高清精品在线| 日本vs亚洲vs韩国一区三区 | 不卡影院免费观看| 久久99国产精品久久99 | 另类小说图片综合网| 1000精品久久久久久久久| 久久天天做天天爱综合色| 欧美系列一区二区| av毛片久久久久**hd|