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