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


C# ObjectInstance.GetMissingPropertyValue方法代码示例

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


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

示例1: GetNamedPropertyValue

        /// <summary>
        /// Gets the value of the property with the given name.  The name cannot be an array index.
        /// </summary>
        /// <param name="propertyName"> The name of the property.  The name cannot be an array index. </param>
        /// <param name="thisValue"> The value of the "this" keyword inside a getter. </param>
        /// <returns> The value of the property, or <c>null</c> if the property doesn't exist. </returns>
        /// <remarks> The prototype chain is searched if the property does not exist directly on
        /// this object. </remarks>
        private object GetNamedPropertyValue(string propertyName, ObjectInstance thisValue)
        {
            ObjectInstance prototypeObject = this;
            do
            {
                // Retrieve information about the property.
                var property = prototypeObject.schema.GetPropertyIndexAndAttributes(propertyName);
                if (property.Exists == true)
                {
                    // The property was found!
                    object value = prototypeObject.propertyValues[property.Index];
                    if ((property.Attributes & (PropertyAttributes.IsAccessorProperty | PropertyAttributes.IsLengthProperty)) == 0)
                        return value;

                    // Call the getter if there is one.
                    if (property.IsAccessor == true)
                        return ((PropertyAccessorValue)value).GetValue(thisValue);

                    // Otherwise, the property is the "magic" length property.
                    return ((ArrayInstance)prototypeObject).Length;
                }

                // Traverse the prototype chain.
                prototypeObject = prototypeObject.prototype;
            } while (prototypeObject != null);

            // The property doesn't exist.
            return thisValue.GetMissingPropertyValue(propertyName);
        }
开发者ID:dusk0r,项目名称:Jurassic,代码行数:37,代码来源:ObjectInstance.cs

示例2: GetPropertyValue

        /// <summary>
        /// Gets the value of the property with the given array index.
        /// </summary>
        /// <param name="index"> The array index of the property. </param>
        /// <param name="thisValue"> The value of the "this" keyword inside a getter. </param>
        /// <returns> The value of the property, or <c>null</c> if the property doesn't exist. </returns>
        /// <remarks> The prototype chain is searched if the property does not exist directly on
        /// this object. </remarks>
        private object GetPropertyValue(uint index, ObjectInstance thisValue)
        {
            // Get the descriptor for the property.
            var property = this.GetOwnPropertyDescriptor(index);
            if (property.Exists == true)
            {
                // The property was found!  Call the getter if there is one.
                object value = property.Value;
                var accessor = value as PropertyAccessorValue;
                if (accessor != null)
                    return accessor.GetValue(thisValue);
                return value;
            }

            // The property might exist in the prototype.
            if (this.prototype == null)
                return thisValue.GetMissingPropertyValue(index.ToString());
            return this.prototype.GetPropertyValue(index, thisValue);
        }
开发者ID:dusk0r,项目名称:Jurassic,代码行数:27,代码来源:ObjectInstance.cs


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