Source/DocumentDock/DocumentBarContainerConverter.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;

namespace DevComponents.DotNetBar
{
	/// <summary>
	/// Represents DocumentBarContainer converter.
	/// </summary>
	public class DocumentBarContainerConverter:TypeConverter
	{
		/// <summary>
		/// Creates new instance of the class.
		/// </summary>
		public DocumentBarContainerConverter(){}

		/// <summary>
		/// Checks whether conversion can be made to specified type.
		/// </summary>
		/// <param name="context">Context Information.</param>
		/// <param name="destinationType">Destination type.</param>
		/// <returns></returns>
		public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
		{
			if(destinationType==typeof(InstanceDescriptor))
				return true;
			return base.CanConvertTo(context, destinationType);
		}

		/// <summary>
		/// Converts object to specified type.
		/// </summary>
		/// <param name="context">Context information.</param>
		/// <param name="culture">Culture information.</param>
		/// <param name="value">Object to convert.</param>
		/// <param name="destinationType">Destination type.</param>
		/// <returns>Object converted to destination type.</returns>
		public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
		{
			if(destinationType==null)
				throw new ArgumentNullException("destinationType");

			if((destinationType==typeof(InstanceDescriptor)) && (value is DocumentBarContainer))
			{
				DocumentBarContainer doc=(DocumentBarContainer)value;
				Type[] constructorParams=null;
				MemberInfo constructorMemberInfo = null;
				object[] constructorValues = null;

				constructorParams = new Type[3] { typeof(Bar),typeof(int),typeof(int) } ;
				constructorMemberInfo = typeof(DocumentBarContainer).GetConstructor(constructorParams);
				constructorValues=new object[3] {doc.Bar,doc.LayoutBounds.Width,doc.LayoutBounds.Height};

				if(constructorMemberInfo!=null)
				{
					return new InstanceDescriptor(constructorMemberInfo, constructorValues);
				}
			}
后面还有 5 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。