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


C# DTypeDesc.GetProperty方法代码示例

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


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

示例1: GetStaticPropertyDesc

        /// <summary>
        /// Gets the <see cref="DPropertyDesc"/> of a static property of a class.
        /// </summary>
        /// <param name="type">The class to get the property of.</param>
        /// <param name="propertyName">The property name.</param>
        /// <param name="caller"><see cref="DTypeDesc"/> of the object that request the retrieval.</param>
        /// <param name="context">Current <see cref="ScriptContext"/>.</param>
        /// <param name="quiet">If <B>true</B>, the &quot;property not found&quot; exception should not be thrown.</param>
        /// <returns>The <see cref="DPropertyDesc"/> representing the static property or <B>null</B> if an error occurs.</returns>
        /// <exception cref="PhpException">The property denoted by <paramref name="propertyName"/> was not found. (Error)</exception>
        /// <exception cref="PhpException">The property is inaccessible due to its protected or private visibility level (Error).
        /// </exception>
        internal static DPropertyDesc GetStaticPropertyDesc(DTypeDesc type, object propertyName, DTypeDesc caller,
            ScriptContext context, bool quiet)
        {
            if (type == null) return null;

            // convert propertyName to string
            string name = (propertyName == null ? String.Empty : Convert.ObjectToString(propertyName));

            // find the property
            DPropertyDesc property;
            switch (type.GetProperty(new VariableName(name), caller, out property))
            {
                case GetMemberResult.NotFound:
                    {
                        if (!quiet) PhpException.UndeclaredStaticProperty(type.MakeFullName(), name);
                        return null;
                    }

                case GetMemberResult.BadVisibility:
                    {
                        if (!quiet)
                        {
                            PhpException.PropertyNotAccessible(
                                property.DeclaringType.MakeFullName(),
                                name,
                                (caller == null ? String.Empty : caller.MakeFullName()),
                                property.IsProtected);
                        }
                        return null;
                    }

                case GetMemberResult.OK:
                    {
                        if (!property.IsStatic) goto case GetMemberResult.NotFound;
                        break;
                    }
            }

            // make sure that the property has been initialized for this request
            property.EnsureInitialized(context);

            return property;
        }
开发者ID:kaviarasankk,项目名称:Phalanger,代码行数:55,代码来源:Operators.cs


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