[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/ccLee627/ClearScript/master/ClearScript/ScriptObject.cs [Back]  [Original]

using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using Microsoft.ClearScript.Util;

namespace Microsoft.ClearScript
{
    /// 
    /// Represents a script object.
    /// 
    /// 
    public abstract class ScriptObject : DynamicObject
    {
        internal ScriptObject()
        {
        }

        /// 
        /// Gets the script engine that owns the object.
        /// 
        public abstract ScriptEngine Engine { get; }

        /// 
        /// Gets the value of a named script object property.
        /// 
        /// The name of the property to get.
        /// Optional arguments for property retrieval.
        /// The value of the specified property.
        public abstract object GetProperty(string name, params object[] args);

        /// 
        /// Sets the value of a named script object property.
        /// 
        /// The name of the property to set.
        /// An array containing optional arguments and the new property value.
        /// 
        /// The  array must contain at least one element. The new
        /// property value must be the last element of the array.
        /// 
        public abstract void SetProperty(string name, params object[] args);

        /// 
        /// Removes a named script object property.
        /// 
        /// The name of the property to remove.
        /// True if the property was removed successfully, false otherwise.
        public abstract bool DeleteProperty(string name);

        /// 
        /// Enumerates the script object's property names.
        /// 
        public abstract IEnumerable PropertyNames { get; }

        /// 
        /// Gets or sets the value of a named script object property.
        /// 
        /// The name of the property to get or set.
        /// Optional arguments for property access.
        /// The value of the specified property.
        public object this[string name, params object[] args]
        {
            get { return GetProperty(name, args); }
            set { SetProperty(name, args.Concat(value.ToEnumerable()).ToArray()); }
        }

        /// 
        /// Gets the value of an indexed script object property.
        /// 
        /// The index of the property to get.
        /// The value of the specified property.
        public abstract object GetProperty(int index);

        /// 
        /// Sets the value of an indexed script object property.
        /// 
        /// The index of the property to set.
        /// The new property value.
        public abstract void SetProperty(int index, object value);

        /// 
        /// Removes an indexed script object property.
        /// 
        /// The index of the property to remove.
        /// True if the property was removed successfully, false otherwise.
        public abstract bool DeleteProperty(int index);

        /// 
        /// Enumerates the script object's property indices.
        /// 
        public abstract IEnumerable PropertyIndices { get; }

        /// 
        /// Gets or sets the value of an indexed script object property.
        /// 
        /// The index of the property to get or set.
        /// The value of the specified property.
        public object this[int index]
        {
            get { return GetProperty(index); }
            set { SetProperty(index, value); }
        }

        /// 
        /// Invokes the script object.
        /// 
        /// True to invoke the object as a constructor, false otherwise.
        /// Optional arguments for object invocation.
        /// The invocation result value.
        public abstract object Invoke(bool asConstructor, params object[] args);

        /// 
        /// Invokes a script object method.
        /// 
        /// The name of the method to invoke.
        /// Optional arguments for method invocation.
        /// The invocation result value.
        public abstract object InvokeMethod(string name, params object[] args);
    }
}

Web Proxy Viewer  |  New URL  |  Original Page