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

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

?? optionconverter.cs

?? 詳細講述了數據庫編程
?? CS
?? 第 1 頁 / 共 2 頁
字號:
//				throw new InvalidOperationException("No type converter defined for [" + target + "]");
//			}
//			return converter;
//		}

		/// <summary>
		/// Checks if there is an appropriate type conversion from the source type to the target type.
		/// </summary>
		/// <param name="sourceType">The type to convert from.</param>
		/// <param name="targetType">The type to convert to.</param>
		/// <returns><c>true</c> if there is a conversion from the source type to the target type.</returns>
		/// <remarks>
		/// Checks if there is an appropriate type conversion from the source type to the target type.
		/// <para>
		/// </para>
		/// </remarks>
		public static bool CanConvertTypeTo(Type sourceType, Type targetType)
		{
			if (sourceType == null || targetType == null)
			{
				return false;
			}

			// Check if we can assign directly from the source type to the target type
			if (targetType.IsAssignableFrom(sourceType))
			{
				return true;
			}

			// Look for a To converter
			IConvertTo tcSource = ConverterRegistry.GetConvertTo(sourceType, targetType);
			if (tcSource != null)
			{
				if (tcSource.CanConvertTo(targetType))
				{
					return true;
				}
			}

			// Look for a From converter
			IConvertFrom tcTarget = ConverterRegistry.GetConvertFrom(targetType);
			if (tcTarget != null)
			{
				if (tcTarget.CanConvertFrom(sourceType))
				{
					return true;
				}
			}

			return false;
		}

		/// <summary>
		/// Converts an object to the target type.
		/// </summary>
		/// <param name="sourceInstance">The object to convert to the target type.</param>
		/// <param name="targetType">The type to convert to.</param>
		/// <returns>The converted object.</returns>
		/// <remarks>
		/// <para>
		/// Converts an object to the target type.
		/// </para>
		/// </remarks>
		public static object ConvertTypeTo(object sourceInstance, Type targetType)
		{
			Type sourceType = sourceInstance.GetType();

			// Check if we can assign directly from the source type to the target type
			if (targetType.IsAssignableFrom(sourceType))
			{
				return sourceInstance;
			}

			// Look for a TO converter
			IConvertTo tcSource = ConverterRegistry.GetConvertTo(sourceType, targetType);
			if (tcSource != null)
			{
				if (tcSource.CanConvertTo(targetType))
				{
					return tcSource.ConvertTo(sourceInstance, targetType);
				}
			}

			// Look for a FROM converter
			IConvertFrom tcTarget = ConverterRegistry.GetConvertFrom(targetType);
			if (tcTarget != null)
			{
				if (tcTarget.CanConvertFrom(sourceType))
				{
					return tcTarget.ConvertFrom(sourceInstance);
				}
			}

			throw new ArgumentException("Cannot convert source object [" + sourceInstance.ToString() + "] to target type [" + targetType.Name + "]", "sourceInstance");
		}

//		/// <summary>
//		/// Finds the value corresponding to <paramref name="key"/> in 
//		/// <paramref name="props"/> and then perform variable substitution 
//		/// on the found value.
//		/// </summary>
//		/// <param name="key">The key to lookup.</param>
//		/// <param name="props">The association to use for lookups.</param>
//		/// <returns>The substituted result.</returns>
//		public static string FindAndSubst(string key, System.Collections.IDictionary props) 
//		{
//			if (props == null)
//			{
//				throw new ArgumentNullException("props");
//			}
//
//			string v = props[key] as string;
//			if (v == null) 
//			{
//				return null;	  
//			}
//	
//			try 
//			{
//				return SubstituteVariables(v, props);
//			} 
//			catch(Exception e) 
//			{
//				LogLog.Error("OptionConverter: Bad option value [" + v + "].", e);
//				return v;
//			}	
//		}

		/// <summary>
		/// Instantiates an object given a class name.
		/// </summary>
		/// <param name="className">The fully qualified class name of the object to instantiate.</param>
		/// <param name="superClass">The class to which the new object should belong.</param>
		/// <param name="defaultValue">The object to return in case of non-fulfillment.</param>
		/// <returns>
		/// An instance of the <paramref name="className"/> or <paramref name="defaultValue"/>
		/// if the object could not be instantiated.
		/// </returns>
		/// <remarks>
		/// <para>
		/// Checks that the <paramref name="className"/> is a subclass of
		/// <paramref name="superClass"/>. If that test fails or the object could
		/// not be instantiated, then <paramref name="defaultValue"/> is returned.
		/// </para>
		/// </remarks>
		public static object InstantiateByClassName(string className, Type superClass, object defaultValue) 
		{
			if (className != null) 
			{
				try 
				{
					Type classObj = SystemInfo.GetTypeFromString(className, true, true);
					if (!superClass.IsAssignableFrom(classObj)) 
					{
						LogLog.Error("OptionConverter: A [" + className + "] object is not assignable to a [" + superClass.FullName + "] variable.");
						return defaultValue;	  
					}
					return Activator.CreateInstance(classObj);
				}
				catch (Exception e) 
				{
					LogLog.Error("OptionConverter: Could not instantiate class [" + className + "].", e);
				}
			}
			return defaultValue;	
		}

		/// <summary>
		/// Performs variable substitution in string <paramref name="val"/> from the 
		/// values of keys found in <paramref name="props"/>.
		/// </summary>
		/// <param name="value">The string on which variable substitution is performed.</param>
		/// <param name="props">The dictionary to use to lookup variables.</param>
		/// <returns>The result of the substitutions.</returns>
		/// <remarks>
		/// <para>
		/// The variable substitution delimiters are <b>${</b> and <b>}</b>.
		/// </para>
		/// <para>
		/// For example, if props contains <c>key=value</c>, then the call
		/// </para>
		/// <para>
		/// <code lang="C#">
		/// string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
		/// </code>
		/// </para>
		/// <para>
		/// will set the variable <c>s</c> to "Value of key is value.".
		/// </para>
		/// <para>
		/// If no value could be found for the specified key, then substitution 
		/// defaults to an empty string.
		/// </para>
		/// <para>
		/// For example, if system properties contains no value for the key
		/// "nonExistentKey", then the call
		/// </para>
		/// <para>
		/// <code lang="C#">
		/// string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
		/// </code>
		/// </para>
		/// <para>
		/// will set <s>s</s> to "Value of nonExistentKey is []".	 
		/// </para>
		/// <para>
		/// An Exception is thrown if <paramref name="value"/> contains a start 
		/// delimiter "${" which is not balanced by a stop delimiter "}". 
		/// </para>
		/// </remarks>
		public static string SubstituteVariables(string value, System.Collections.IDictionary props) 
		{
			StringBuilder buf = new StringBuilder();

			int i = 0;
			int j, k;
	
			while(true) 
			{
				j = value.IndexOf(DELIM_START, i);
				if (j == -1) 
				{
					if (i == 0)
					{
						return value;
					}
					else 
					{
						buf.Append(value.Substring(i, value.Length - i));
						return buf.ToString();
					}
				}
				else 
				{
					buf.Append(value.Substring(i, j - i));
					k = value.IndexOf(DELIM_STOP, j);
					if (k == -1) 
					{
						throw new LogException("[" + value + "] has no closing brace. Opening brace at position [" + j + "]");
					}
					else 
					{
						j += DELIM_START_LEN;
						string key = value.Substring(j, k - j);

						string replacement = props[key] as string;

						if (replacement != null) 
						{
							buf.Append(replacement);
						}
						i = k + DELIM_STOP_LEN;		
					}
				}
			}
		}

		#endregion Public Static Methods

		#region Private Static Methods

		/// <summary>
		/// Converts the string representation of the name or numeric value of one or 
		/// more enumerated constants to an equivalent enumerated object.
		/// </summary>
		/// <param name="enumType">The type to convert to.</param>
		/// <param name="value">The enum string value.</param>
		/// <param name="ignoreCase">If <c>true</c>, ignore case; otherwise, regard case.</param>
		/// <returns>An object of type <paramref name="enumType" /> whose value is represented by <paramref name="value" />.</returns>
		private static object ParseEnum(System.Type enumType, string value, bool ignoreCase) 
		{
#if !NETCF
			return Enum.Parse(enumType, value, ignoreCase);
#else
			FieldInfo[] fields = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);

			string[] names = value.Split(new char[] {','});
			for (int i = 0; i < names.Length; ++i) 
			{
				names[i] = names [i].Trim();
			}

			long retVal = 0;

			try 
			{
				// Attempt to convert to numeric type
				return Enum.ToObject(enumType, Convert.ChangeType(value, typeof(long), CultureInfo.InvariantCulture));
			} 
			catch {}

			foreach (string name in names) 
			{
				bool found = false;
				foreach(FieldInfo field in fields) 
				{
					if (String.Compare(name, field.Name, ignoreCase) == 0) 
					{
						retVal |= ((IConvertible) field.GetValue(null)).ToInt64(CultureInfo.InvariantCulture);
						found = true;
						break;
					}
				}
				if (!found) 
				{
					throw new ArgumentException("Failed to lookup member [" + name + "] from Enum type [" + enumType.Name + "]");
				}
			}
			return Enum.ToObject(enumType, retVal);
#endif
		}		

		#endregion Private Static Methods

		#region Private Static Fields

		private const string DELIM_START = "${";
		private const char   DELIM_STOP  = '}';
		private const int DELIM_START_LEN = 2;
		private const int DELIM_STOP_LEN  = 1;

		#endregion Private Static Fields
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品99久久久久| 国产在线日韩欧美| 国产欧美一区二区在线| 色视频成人在线观看免| 美女网站一区二区| 亚洲情趣在线观看| 久久久精品中文字幕麻豆发布| 色天使色偷偷av一区二区| 国产麻豆成人传媒免费观看| 亚洲线精品一区二区三区| 久久久久久久久久久久久久久99 | 久久精品一区蜜桃臀影院| 91成人国产精品| 国产精品一二三| 美女视频黄频大全不卡视频在线播放| 国产精品久久久久久久午夜片| 884aa四虎影成人精品一区| 色综合中文综合网| 国产精品国产三级国产有无不卡 | 欧美日韩免费一区二区三区| 国产成人一区在线| 热久久国产精品| 亚洲成人免费av| 亚洲猫色日本管| 国产精品久久国产精麻豆99网站| 2020日本不卡一区二区视频| 欧美一级淫片007| 欧美视频在线播放| 日本精品一级二级| 99视频精品免费视频| 国产a久久麻豆| 国产精品自拍av| 韩国av一区二区三区四区| 日韩电影在线一区二区三区| 亚洲第一狼人社区| 亚洲不卡av一区二区三区| 一区二区三区av电影| 一区二区三区自拍| 一区二区三区在线看| 亚洲人妖av一区二区| 中文字幕日本乱码精品影院| 国产精品高潮呻吟| 国产精品视频一区二区三区不卡| 国产日韩欧美精品综合| 国产日韩欧美精品在线| 国产精品欧美久久久久一区二区| 国产日韩影视精品| 亚洲欧洲日韩综合一区二区| 日韩美女视频一区| 亚洲国产婷婷综合在线精品| 亚洲国产成人av网| 日韩黄色小视频| 美女视频一区在线观看| 韩日欧美一区二区三区| 国产精品亚洲一区二区三区在线| 国产高清精品久久久久| 成年人午夜久久久| 91蜜桃视频在线| 欧美日韩国产在线观看| 91精品国产91热久久久做人人| 日韩视频免费直播| 久久久久久影视| 中文字幕一区二区不卡| 亚洲国产成人精品视频| 免费看欧美美女黄的网站| 精品一区二区在线观看| 成人一区二区三区在线观看| 在线观看免费成人| 欧美成人性福生活免费看| 国产日韩欧美一区二区三区综合| 亚洲色图丝袜美腿| 婷婷久久综合九色综合伊人色| 久久国产精品99久久久久久老狼 | 日韩美女视频在线| 国产色产综合色产在线视频| 亚洲欧美福利一区二区| 日韩精品电影在线观看| 国产综合色视频| 色诱亚洲精品久久久久久| 91精品婷婷国产综合久久性色| 日韩欧美一卡二卡| 国产精品日产欧美久久久久| 亚洲最色的网站| 精品一区二区三区在线播放| 99视频有精品| 日韩精品自拍偷拍| 亚洲精品网站在线观看| 久久精品72免费观看| 99re66热这里只有精品3直播| 678五月天丁香亚洲综合网| 久久久精品2019中文字幕之3| 亚洲老司机在线| 国产一区二区三区四区在线观看| 91蜜桃婷婷狠狠久久综合9色| 欧美变态凌虐bdsm| 亚洲激情综合网| 国产精品自产自拍| 欧美精品99久久久**| 国产精品免费视频网站| 蜜臀久久99精品久久久久宅男| 大陆成人av片| 精品福利一区二区三区| 亚洲一线二线三线视频| 成人一区二区视频| 精品国产露脸精彩对白| 亚洲一区二区三区中文字幕在线| 成人午夜激情在线| 日韩精品中文字幕一区二区三区| 亚洲精品视频免费观看| 国产999精品久久久久久绿帽| 日韩亚洲欧美一区二区三区| 一区二区在线看| 粉嫩嫩av羞羞动漫久久久| 日韩久久久久久| 五月婷婷久久综合| 91网站最新地址| 国产精品少妇自拍| 韩日精品视频一区| 精品免费视频.| 日本不卡视频一二三区| 欧美综合欧美视频| 亚洲美腿欧美偷拍| 一本一道久久a久久精品综合蜜臀| 久久久一区二区三区| 久久精品国产久精国产| 在线成人免费视频| 亚洲午夜激情网站| 欧美三级一区二区| 亚洲国产精品久久不卡毛片 | 欧美精品一区二区在线播放| 午夜精品久久久久久久99樱桃| 91黄色在线观看| 一区二区三区四区亚洲| 91亚洲资源网| 亚洲区小说区图片区qvod| av动漫一区二区| 日韩一区中文字幕| av成人免费在线| 日韩美女啊v在线免费观看| 不卡av电影在线播放| 国产精品高潮久久久久无| 不卡在线观看av| 中文字幕一区二区三| 99精品欧美一区二区三区综合在线| 国产精品久久久久久久久果冻传媒 | 久久精品国产免费| 久久久精品中文字幕麻豆发布| 国产在线看一区| 国产欧美日本一区视频| 福利电影一区二区三区| 国产精品传媒入口麻豆| 91丨九色丨蝌蚪丨老版| 亚洲另类春色国产| 欧美精品日日鲁夜夜添| 免费一级片91| 久久久久久久久久看片| 99久免费精品视频在线观看| 亚洲男女一区二区三区| 欧美日韩精品一区二区三区蜜桃| 天堂在线亚洲视频| 2021国产精品久久精品| 99综合电影在线视频| 一区二区三区影院| 欧美一级欧美一级在线播放| 国产一区二区在线视频| 国产精品久久一卡二卡| 欧美亚洲高清一区| 美女脱光内衣内裤视频久久网站 | 久久久久久久精| 91亚洲精品久久久蜜桃网站 | 粉嫩av一区二区三区粉嫩| 亚洲精品高清在线观看| 日韩欧美国产1| 99视频热这里只有精品免费| 天天做天天摸天天爽国产一区| 久久众筹精品私拍模特| 91一区二区三区在线观看| 日韩电影在线一区| 中文字幕一区二区三区精华液 | 国产成人精品一区二区三区网站观看| 亚洲欧洲国产日韩| 欧美一级在线视频| 91在线porny国产在线看| 美女高潮久久久| 亚洲精品中文字幕乱码三区| 日韩精品一区二区三区在线观看 | 中文天堂在线一区| 欧美日本在线播放| 国产91精品一区二区麻豆网站 | 日韩一区二区麻豆国产| 成人av在线网| 91官网在线免费观看| 国产一区二区美女诱惑| 一区二区三区免费观看| 日韩精品一区二区三区视频在线观看 | 欧美videos中文字幕| 一本到高清视频免费精品| 狠狠色丁香婷婷综合久久片| 亚洲精品第一国产综合野| 国产午夜精品美女毛片视频|