namespace Jint.Runtime.Descriptors { /// /// An element of a javascript object /// public abstract class PropertyDescriptor { public static PropertyDescriptor Undefined = new UndefinedPropertyDescriptor(); /// /// If true, the property will be enumerated by a for-in /// enumeration (see 12.6.4). Otherwise, the property is said /// to be non-enumerable. /// public bool Enumerable { get; set; } /// /// If false, attempts to delete the property, change the /// property to be a data property, or change its attributes will /// fail. /// public bool Configurable { get; set; } /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-8.10.1 /// /// public abstract bool IsAccessorDescriptor(); /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-8.10.2 /// /// public abstract bool IsDataDescriptor(); /// /// http://www.ecma-international.org/ecma-262/5.1/#sec-8.10.3 /// /// public bool IsGenericDescriptor() { return !IsDataDescriptor() && !IsAccessorDescriptor(); } public T As() where T : PropertyDescriptor { return (T)this; } /// /// Local implementation used to create a singleton representing /// an undefined result of a PropertyDescriptor. This prevents the rest /// of the code to return 'object' in order to be able to return /// Undefined.Instance /// internal sealed class UndefinedPropertyDescriptor : PropertyDescriptor { public override bool IsAccessorDescriptor() { throw new System.NotImplementedException(); } public override bool IsDataDescriptor() { throw new System.NotImplementedException(); } } } }