CreateRootObject() static private method

Creates an Object with no prototype to serve as the base prototype of all objects.
static private CreateRootObject ( ScriptEngine engine ) : ObjectInstance
engine ScriptEngine The script engine associated with this object.
return ObjectInstance
Exemplo n.º 1
0
        public static ObjectInstance Create(ScriptEngine engine, object prototype, [DefaultParameterValue(null)] ObjectInstance properties = null)
        {
            if ((prototype is ObjectInstance) == false && prototype != Null.Value)
            {
                throw new JavaScriptException(engine, "TypeError", "object prototype must be an object or null");
            }
            ObjectInstance result;

            if (prototype == Null.Value)
            {
                result = ObjectInstance.CreateRootObject(engine);
            }
            else
            {
                result = ObjectInstance.CreateRawObject((ObjectInstance)prototype);
            }
            if (properties != null)
            {
                DefineProperties(result, properties);
            }
            return(result);
        }