當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。