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


C# DType.GetProperty方法代码示例

本文整理汇总了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);
			}
		}
开发者ID:Ashod,项目名称:Phalanger,代码行数:61,代码来源:Analyzer.cs


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