本文整理汇总了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;
}