当前位置: 首页>>代码示例>>C#>>正文


C# Property.Resolve方法代码示例

本文整理汇总了C#中System.Property.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# Property.Resolve方法的具体用法?C# Property.Resolve怎么用?C# Property.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Property的用法示例。


在下文中一共展示了Property.Resolve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApplyProperty

		///<summary>
		/// This method sets the concrete property on a concrete widget. It is the most important
		/// method to get the defined properties reflected in the User Interface
		///</summary>
		///<param name="uiObject">The (widget set dependent) object that represents the part in the widget set</param>
		///<param name="p"></param>
		///<param name="part"></param>
		///<param name="tclassType"></param>
		private System.Object ApplyProperty(ref System.Object uiObject, Property p, Part part, Type tclassType)
		{
			if (p.IsVirtual)
			{
				// don't do anything, just return the widget
				return uiObject;
			}
			string setter = Voc.GetPropertySetter(p.Name, part.Class);
            DParam[] parameters = Voc.GetParams(p.Name, part.Class, "setMethod");

			//try to use Properties first,
			//if that fails, look for the appropriate setters in the available methods
			try
			{
				Type classType = tclassType;
				System.Object targetObject = uiObject;
				PropertyInfo pInfo = null;
				int j = setter.IndexOf('.');
				while(j!=-1)
				{
					String parentType = setter.Substring(0,j);
					setter=setter.Substring(j+1,setter.Length-j-1);
					pInfo = classType.GetProperty(parentType);
					classType = pInfo.PropertyType;
					targetObject = pInfo.GetValue(targetObject, null);
					j = setter.IndexOf('.');
				}

                MemberInfo memInfo = GetMemberInfo(setter, classType, part, p);

                if (memInfo == null)
                {
                    // throw some error here, about not having the appropriate member
                    Console.WriteLine("Warning: could not load setter \"{0}\" for {1} (type {2}), please check your vocabulary", setter, part.Identifier, tclassType.FullName);
                    return uiObject;
                }

				//if lazy, resolve property value first
				if(p.Lazy)
					p.Resolve(this);

				//
				if (memInfo is PropertyInfo)
					SetProperty(targetObject, p, (PropertyInfo)memInfo);
				else
					InvokeMethod(targetObject, part, p, (MethodInfo)memInfo);
			}
			/*
			catch(TypeLoadException tle)
			{
				return ApplyAdHocProperty(ref uiObject, part, p);
			} 
			*/
			catch(NullReferenceException nre)
			{
				Console.WriteLine("Warning: could not load setter \"{0}\" for {1} (type {2}), please check your vocabulary", setter, part.Identifier, tclassType.FullName);
			}
			catch(Exception e)
			{
				Console.WriteLine("Setting property [{0}] with value [{1}] failed for [{2}]", setter, p.Value, part.Identifier);
				Console.WriteLine(e);
				Console.WriteLine("Trying to continue...");
			}
			return uiObject;
		}
开发者ID:jozilla,项目名称:Uiml.net,代码行数:73,代码来源:Renderer.cs


注:本文中的System.Property.Resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。