Asp.net 3.5控件和组件开发技术系列—服务器控件属性(四)
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-05-20
= culture.TextInfo.ListSeparator[0]; string[] strArray = str2.Split(new char[] { ch }); int[] numArray = new int[strArray.Length]; TypeConverter converter = TypeDescriptor.GetConverter(typeof(int)); for (int i = 0; i < numArray.Length; i++) { numArray[i] = (int)converter.ConvertFromString (context,culture,strArray[i]); } if (numArray.Length != 3) { throw new Exception("鯉塀音屎鳩!"); } return new SolidCoordinate(numArray[0],numArray[1],numArray[2]); } public override object ConvertTo(ITypeDescriptorContext context,CultureInfo culture,object value,Type destinationType) { if (destinationType == null) { throw new Exception("朕炎窃侏音嬬葎腎!"); } if (value is SolidCoordinate) { if (destinationType == typeof(string)) { SolidCoordinate solidCoordinate = (SolidCoordinate)value; if (culture == null) { culture = CultureInfo.CurrentCulture; } string separator = culture.TextInfo.ListSeparator + " "; TypeConverter converter=TypeDescriptor.GetConverter(typeof (int)); string[] strArray = new string[3]; int num = 0; strArray[num++] = converter.ConvertToString (context,culture,solidCoordinate.X); strArray[num++] = converter.ConvertToString (context,culture,solidCoordinate.Y); strArray[num++] = converter.ConvertToString (context,culture,solidCoordinate.Z); return string.Join(separator,strArray); } if (destinationType == typeof(InstanceDescriptor)) { SolidCoordinate solidCoordinate2 = (SolidCoordinate)value; ConstructorInfo constructor = typeof(SolidCoordinate). GetConstructor(new Type[] { typeof(int),typeof(int),typeof(int) }); if (constructor != null) { return new InstanceDescriptor(constructor,new object[] { solidCoordinate2.X,solidCoordinate2.Y,solidCoordinate2.Z }); } } } return base.ConvertTo(context,culture,value,destinationType); } public override bool GetCreateInstanceSupported(ITypeDescriptorContext context) { return true; } public override object CreateInstance(ITypeDescriptorContext context,IDictionary propertyValues) { if (propertyValues == null) { throw new Exception("奉來峙音嬬葎腎!"); } object obj2 = propertyValues["X"]; object obj3 = propertyValues["Y"]; |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Asp.net 3.5控件和组件开发技术系列—服务器控件属性(四)的所有评论