本文整理汇总了C#中DType.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# DType.GetProperty方法的具体用法?C# DType.GetProperty怎么用?C# DType.GetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DType
的用法示例。
在下文中一共展示了DType.GetProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveProperty
/// <summary>
/// Resolves static properties.
/// </summary>
public DProperty/*!*/ ResolveProperty(DType/*!*/ type, VariableName propertyName, Position position, bool staticOnly,
PhpType referringType, PhpRoutine referringRoutine, out bool checkVisibilityAtRuntime)
{
Debug.Assert(type != null);
checkVisibilityAtRuntime = false;
// we cannot resolve a property unless we know the inherited members:
if (type.IsDefinite)
{
DProperty property;
GetMemberResult member_result = type.GetProperty(propertyName, referringType, out property);
switch (member_result)
{
case GetMemberResult.OK:
if (staticOnly && !property.IsStatic) goto case GetMemberResult.NotFound;
return property;
case GetMemberResult.NotFound:
ErrorSink.Add(Errors.UnknownPropertyAccessed, SourceUnit, position, type.FullName, propertyName);
return new UnknownProperty(type, propertyName.Value);
case GetMemberResult.BadVisibility:
if (referringType == null && referringRoutine == null)
{
// visibility must be checked at run-time:
checkVisibilityAtRuntime = true;
return property;
}
else
{
// definitive error:
if (property.IsPrivate)
{
ErrorSink.Add(Errors.PrivatePropertyAccessed, SourceUnit, position, type.FullName, propertyName.Value,
referringType.FullName);
}
else
{
ErrorSink.Add(Errors.ProtectedPropertyAccessed, SourceUnit, position, type.FullName, propertyName.Value,
referringType.FullName);
}
return new UnknownProperty(type, propertyName.Value);
}
default:
Debug.Fail();
throw null;
}
}
else
{
// warning (if any) reported by the type resolver:
return new UnknownProperty(type, propertyName.Value);
}
}