Inheritance: ObjectInstance
Esempio n. 1
0
 public string Combine(ArrayInstance pathParts)
 {
     var str = pathParts.ElementValues
         .Select(c => c.ToString())
         .ToArray();
     return System.IO.Path.Combine(str);
 }
Esempio n. 2
0
    public static object ToJs(object ToConvert)
    {
        if (ToConvert is Vector3)
        {
            Vector3 Vec = (Vector3)ToConvert;
            Jurassic.Library.ArrayInstance ArrVec = Scripting.ConsoleEngine.Array.Construct();
            ArrVec.Push((double)Vec.x);
            ArrVec.Push((double)Vec.y);
            ArrVec.Push((double)Vec.z);
            return(ArrVec);
        }

        if (ToConvert is float)
        {
            return(Convert.ToDouble((float)ToConvert));
        }

        if (ToConvert is int)
        {
            return(Convert.ToDouble((int)ToConvert));
        }

        //*Should* be a supported type already
        return(ToConvert);
    }
Esempio n. 3
0
        /// <summary>
        /// Converts dbUser to User and adds it to Users list
        /// </summary>
        /// <param name="dbUser"></param>
        public void addUserFromDB(DBUser dbUser)
        {
            User user = new User(dbUser, this);

            Ship ship = new ShipBuilder().BuildShip(user,
                new PresetShipRepository().GetShip(dbUser.ShipPresetId),
                dbUser.CellTypes);

            //Form array of Cells to be used in JavaScript
            ArrayInstance[] array = new ArrayInstance[ship.cells.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = user.engine.Array.New(ship.cells[i]);

                for (int j = 0; j < ship.cells[i].Length; j++)
                {
                    if (ship.cells[i][j] is CellEngine)
                    {
                        ((CellEngine)ship.cells[i][j]).repository = this;
                    }
                }
            }
            user.engine.SetGlobalValue("cells", user.engine.Array.New(array));
            user.engine.SetGlobalValue("radar", new Radar(user));

            Action<string> logAction = delegate(string s) { user.Log.Add(s); };
            user.engine.SetGlobalFunction("log", logAction);

            user.Login = dbUser.Username;
            user.PasswordHash = dbUser.PasswordHash;
            user.Code = dbUser.Code;
            user.Credits = dbUser.Credits;
            user.ship = ship;
            _users.Add(user);
        }
Esempio n. 4
0
        private void WriteArray(XmlElement parent, string name, ArrayInstance array)
        {
            XmlElement element = _doc.CreateElement(name);
            System.Console.WriteLine("writing {0} elements", array.Length);
            for (int i = 0; i < array.Length; ++i)
            {
                var obj = array[i];
                if (obj is FunctionInstance) continue;

                if (obj is ObjectInstance)
                    WriteObject(element, "o_" + i, obj as ObjectInstance);
                else if (obj is ArrayInstance)
                    WriteArray(element, "a_" + i, obj as ArrayInstance);
                else
                    WritePrimitive(element, i.ToString(), obj);
            }
            parent.AppendChild(element);
        }
Esempio n. 5
0
 public void PointSeries(ArrayInstance array, ColorInstance color)
 {
     Color c = color.GetColor();
     Vertex[] verts = new Vertex[array.Length];
     for (var i = 0; i < array.Length; ++i)
     {
         Vector2f vect = GlobalPrimitives.GetVector(array[i] as ObjectInstance);
         verts[i] = new Vertex(vect, c);
     }
     _batch.AddVerts(verts, verts.Length, PrimitiveType.Points);
     _changed = true;
 }
Esempio n. 6
0
 public void LineSeries(ArrayInstance points, ColorInstance color)
 {
     _changed = true;
 }
Esempio n. 7
0
        internal void addChat(ArrayInstance chatNodes)
        {
            List<ChatNode> result = new List<ChatNode>();

            for (int i = 0; i < chatNodes.Length; i++)
            {
                ObjectInstance obj = chatNodes[i] as ObjectInstance;
                if (obj == null)
                    continue;

                string str = obj.GetPropertyValue("text") as string;
                object oTxt = obj.GetPropertyValue("text");
                if (oTxt == null) continue;
                str = oTxt.ToString();

                ColorInstance color = obj.GetPropertyValue("color") as ColorInstance;
                string cssClass = obj.GetPropertyValue("cssClass") as string;

                if (str == null)
                    continue;
                else if (color == null && cssClass == null)
                    continue;

                ChatNode node;
                if (color == null)
                {
                    node = new ChatNode(str, cssClass);
                }
                else
                {
                    node = new ChatNode(str, Color.FromArgb(255, color.R, color.G, color.B));
                }

                result.Add(node);
            }

            try
            {
                _client.MainWindow.AddChat(result);
            }
            catch (Exception ex)
            {
                throw new JavaScriptException(_engine, ex.GetType().Name, ex.Message);
            }
        }
Esempio n. 8
0
        public string format(string fmtString, ArrayInstance args)
        {
            object[] arguments = new object[args.Length];
            for (int i = 0; i < args.Length; i++)
                arguments[i] = args[i];

            return string.Format(fmtString, arguments);
        }
 private void NotifyResults(ArrayInstance result)
 {
     if (result != null)
     {
         foreach (object message in result.ElementValues)
             _eventNotifier.SendText(message.ToString());
     }
 }
Esempio n. 10
0
 // is this even being used?
 public static void OutlinedRectangles(ArrayInstance items, ColorInstance color)
 {
     uint size = items.Length * 4;
     Color c = color.GetColor();
     Vertex[] verts = new Vertex[size];
     for (var i = 0; i < size; i += 4)
     {
         ObjectInstance rect = items[i / 4] as ObjectInstance;
         int x1 = (int)rect["x"];
         int y1 = (int)rect["y"];
         int x2 = x1 + (int)rect["w"];
         int y2 = y1 + (int)rect["h"];
         verts[i + 0] = new Vertex(new Vector2f(x1, y1), c);
         verts[i + 1] = new Vertex(new Vector2f(x2, y1), c);
         verts[i + 2] = new Vertex(new Vector2f(x2, y2), c);
         verts[i + 3] = new Vertex(new Vector2f(x1, y2), c);
     }
     Program.Batch.AddVerts(verts, verts.Length, PrimitiveType.LinesStrip);
 }
Esempio n. 11
0
    static List <object> GetDelCall(string Name)
    {
        switch (Name)
        {
        case "print":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToPrint){ Console.Print(ToPrint); })
            });

        case "log":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToLog){ Console.Log(ToLog); })
            });

        case "host":
            return(new List <object> {
                Name, new Action(delegate(){
                    Net.Host();
                })
            });

        case "connect":
            return(new List <object> {
                Name, new Action <string>(delegate(string Ip){
                    if (Ip == "" || Ip == "localhost" || Ip == "undefined")
                    {
                        Ip = "127.0.0.1";
                    }
                    Net.ConnectTo(Ip);
                })
            });

        case "ms_get":
            return(new List <object> {
                Name, new Func <int>(() => { return OS.GetTicksMsec(); })
            });

        case "peerlist_get":
            return(new List <object> {
                Name, new Func <Jurassic.Library.ArrayInstance>(() => {
                    Jurassic.Library.ArrayInstance Out = Scripting.ConsoleEngine.Array.Construct();
                    foreach (int Id in Net.PeerList)
                    {
                        Out.Push(Id);
                    }
                    return Out;
                })
            });

        case "bind":
            return(new List <object> {
                Name, new Action <string, string>(delegate(string FunctionName, string InputString){
                    Bindings.Bind(FunctionName, InputString);
                })
            });

        case "unbind":
            return(new List <object> {
                Name, new Action <string>(delegate(string FunctionName){
                    Bindings.UnBind(FunctionName);
                })
            });

        case "player_input_forward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.ForwardMove(Sens);
                })
            });

        case "player_input_forward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.ForwardSens; })
            });

        case "player_input_backward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.BackwardMove(Sens);
                })
            });

        case "player_input_backward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.BackwardSens; })
            });

        case "player_input_right_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.RightMove(Sens);
                })
            });

        case "player_input_right_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.RightSens; })
            });

        case "player_input_left_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LeftMove(Sens);
                })
            });

        case "player_input_left_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.LeftSens; })
            });

        case "player_input_sprint_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Sprint(Sens);
                })
            });

        case "player_input_sprint_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsSprinting ? 1d : 0d; })
            });

        case "player_input_jump_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Jump(Sens);
                })
            });

        case "player_input_jump_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsJumping ? 1d : 0d; })
            });

        case "player_input_inventory_up":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryUp();
                })
            });

        case "player_input_inventory_down":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryDown();
                })
            });

        case "player_input_look_up":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookUp(Sens);
                })
            });

        case "player_input_look_down":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookDown(Sens);
                })
            });

        case "player_input_look_right":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookRight(Sens);
                })
            });

        case "player_input_look_left":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookLeft(Sens);
                })
            });

        case "player_input_primary_fire":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.PrimaryFire(Sens);
                })
            });

        default:
            throw new System.ArgumentException("Invalid GetDelCall name arg '" + Name + "'");
        }
    }
Esempio n. 12
0
 public void LineSeries(ArrayInstance points, ColorInstance color)
 {
     int c = color.GetInt();
     fixed (byte* buf = _pixels)
     {
         for (var i = 1; i < points.Length; i += 2)
         {
             Vector2f start = GlobalPrimitives.GetVector(points[i - 1] as ObjectInstance);
             Vector2f end = GlobalPrimitives.GetVector(points[i] as ObjectInstance);
             Line(buf, (int)start.X, (int)start.Y, (int)end.X, (int)end.Y, c);
         }
     }
     _changed = true;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="arrayInstance">The watched object</param>
 public ArrayInstanceDebugView(ArrayInstance arrayInstance)
 {
     this.arrayInstance = arrayInstance;
 }
Esempio n. 14
0
        public static void Polygon(ArrayInstance points, ColorInstance color, [DefaultParameterValue(false)] bool inverse = false)
        {
            if (points == null || color == null)
                throw new NullReferenceException();

            Color c = color.GetColor();

            Vertex[] v = new Vertex[points.Length];
            for (var i = 0; i < points.Length; ++i)
            {
                ObjectInstance obj = points[i] as ObjectInstance;
                v[i] = new Vertex(GetVector(obj), c);
            }

            Program.Batch.AddVerts(v, v.Length, PrimitiveType.TrianglesFan);
        }
Esempio n. 15
0
        public static void PointSeries(ArrayInstance points, ColorInstance color)
        {
            Program.Batch.Flush();
            if (points == null || color == null)
                throw new NullReferenceException();

            Color sfml_col = color.GetColor();

            Vertex[] v = new Vertex[points.Length];
            for (var i = 0; i < points.Length; ++i)
            {
                ObjectInstance obj = points[i] as ObjectInstance;
                if (obj != null)
                    v[i] = new Vertex(GetVector(obj), sfml_col);
                else
                    throw new NullReferenceException();
            }

            Program.Batch.AddVerts(v, v.Length, PrimitiveType.Points);
        }
Esempio n. 16
0
 public void AddChat(ArrayInstance items)
 {
     _js.addChat(items);
 }
Esempio n. 17
0
    static List <object> GetDelCall(string Name)
    {
        switch (Name)
        {
        case "print":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToPrint){ Console.Print(ToPrint); })
            });

        case "log":
            return(new List <object> {
                Name, new Action <string>(delegate(string ToLog){ Console.Log(ToLog); })
            });

        case "host":
            return(new List <object> {
                Name, new Action(delegate(){
                    Net.Host();
                })
            });

        case "connect":
            return(new List <object> {
                Name, new Action <string>(delegate(string Ip){
                    if (Ip == "" || Ip == "localhost" || Ip == "undefined")
                    {
                        Ip = "127.0.0.1";
                    }
                    Net.ConnectTo(Ip);
                })
            });

        case "disconnect":
            return(new List <object> {
                Name, new Action(delegate(){
                    Net.Disconnect();
                })
            });

        case "ms_get":
            return(new List <object> {
                Name, new Func <int>(() => { return OS.GetTicksMsec(); })
            });

        case "peerlist_get":
            return(new List <object> {
                Name, new Func <Jurassic.Library.ArrayInstance>(() => {
                    Jurassic.Library.ArrayInstance Out = Scripting.ConsoleEngine.Array.Construct();
                    foreach (int Id in Net.PeerList)
                    {
                        Out.Push(Id);
                    }
                    return Out;
                })
            });

        case "bind":
            return(new List <object> {
                Name, new Action <string, string>(delegate(string FunctionName, string InputString){
                    Bindings.Bind(FunctionName, InputString);
                })
            });

        case "unbind":
            return(new List <object> {
                Name, new Action <string>(delegate(string FunctionName){
                    Bindings.UnBind(FunctionName);
                })
            });

        case "player_input_forward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.ForwardMove(Sens);
                })
            });

        case "player_input_forward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.ForwardSens; })
            });

        case "player_input_backward_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.BackwardMove(Sens);
                })
            });

        case "player_input_backward_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.BackwardSens; })
            });

        case "player_input_right_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.RightMove(Sens);
                })
            });

        case "player_input_right_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.RightSens; })
            });

        case "player_input_left_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LeftMove(Sens);
                })
            });

        case "player_input_left_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.LeftSens; })
            });

        case "player_input_sprint_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Sprint(Sens);
                })
            });

        case "player_input_sprint_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsSprinting ? 1d : 0d; })
            });

        case "player_input_jump_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.Jump(Sens);
                })
            });

        case "player_input_jump_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Game.PossessedPlayer.IsJumping ? 1d : 0d; })
            });

        case "player_input_inventory_up":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryUp();
                })
            });

        case "player_input_inventory_down":
            return(new List <object> {
                Name, new Action(delegate(){
                    Game.PossessedPlayer.InventoryDown();
                })
            });

        case "player_input_look_up":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookUp(Sens);
                })
            });

        case "player_input_look_down":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookDown(Sens);
                })
            });

        case "player_input_look_right":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookRight(Sens);
                })
            });

        case "player_input_look_left":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.LookLeft(Sens);
                })
            });

        case "player_input_build_rotate":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.BuildRotate(Sens);
                })
            });

        case "player_input_primary_fire":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.PrimaryFire(Sens);
                })
            });

        case "player_input_secondary_fire":
            return(new List <object> {
                Name, new Action <double>(delegate(double Sens){
                    Game.PossessedPlayer.SecondaryFire(Sens);
                })
            });

        case "gamemode_set":
            return(new List <object> {
                Name, new Action <string>(delegate(string GameModeName){
                    if (Game.Self.GetTree().GetNetworkPeer() != null && Game.Self.GetTree().GetNetworkUniqueId() == 1)
                    {
                        Scripting.LoadGameMode(GameModeName);
                    }
                    else
                    {
                        Console.Print("Error: Cannot set gamemode as client");
                    }
                })
            });

        case "gamemode_get":
            return(new List <object> {
                Name, new Func <string>(() => { return Scripting.GamemodeName; })
            });

        case "chunk_render_distance_set":
            return(new List <object> {
                Name, new Action <double>(delegate(double Distance){
                    if (Distance < 2d)
                    {
                        Console.Print("Cannot set render distance value lower than two chunks");
                        return;
                    }
                    Game.ChunkRenderDistance = (int)Distance;
                    Game.PossessedPlayer.UnloadAndRequestChunks();
                })
            });

        case "chunk_render_distance_get":
            return(new List <object> {
                Name, new Func <double>(() => { return Convert.ToDouble(Game.ChunkRenderDistance); })
            });

        case "save":
            return(new List <object> {
                Name, new Action(delegate(){
                    Building.SaveWorld("TestSave");
                })
            });

        case "load":
            return(new List <object> {
                Name, new Action(delegate(){
                    Building.LoadWorld("TestSave");
                })
            });

        default:
            throw new System.ArgumentException("Invalid GetDelCall name arg '" + Name + "'");
        }
    }
Esempio n. 18
0
        public static ArrayInstance Map(ObjectInstance thisObj, FunctionInstance callbackFunction, [DefaultParameterValue(null)] ObjectInstance context = null)
        {
            // callbackFunction must be a valid function.
            if (callbackFunction == null)
                throw new JavaScriptException(thisObj.Engine, "TypeError", "Invalid callback function");

            // Get the length of the array.
            uint arrayLength = GetLength(thisObj);

            // This method only supports arrays of length up to 2^31-1.
            if (arrayLength > int.MaxValue)
                throw new JavaScriptException(thisObj.Engine, "RangeError", "The array is too long");

            // Create a new array to hold the new values.
            // The length of the output array is always equal to the length of the input array.
            var resultArray = new ArrayInstance(thisObj.Engine.Array.InstancePrototype, arrayLength, arrayLength);

            for (int i = 0; i < arrayLength; i++)
            {
                // Get the value of the array element.
                object elementValue = thisObj[(uint)i];

                // Only call the callback function for array elements that exist in the array.
                if (elementValue != null)
                {
                    // Call the callback function.
                    object result = callbackFunction.CallLateBound(context, elementValue, i, thisObj);

                    // Store the result.
                    resultArray[(uint)i] = result;
                }
            }

            return resultArray;
        }
        /// <summary>
        /// Transforms the value stored in the given object using toJSON and/or the replacer function.
        /// </summary>
        /// <param name="holder"> The object containing the value. </param>
        /// <param name="arrayIndex"> The array index of the property holding the value to transform. </param>
        /// <returns> The transformed value. </returns>
        private object TransformPropertyValue(ArrayInstance holder, uint arrayIndex)
        {
            string propertyName = null;
            object value = holder[arrayIndex];

            // Transform the value by calling toJSON(), if the method exists on the object.
            if (value is ObjectInstance)
            {
                propertyName = arrayIndex.ToString();
                object toJSONResult;
                if (((ObjectInstance)value).TryCallMemberFunction(out toJSONResult, "toJSON", propertyName) == true)
                    value = toJSONResult;
            }

            // Transform the value by calling the replacer function, if one was provided.
            if (this.ReplacerFunction != null)
            {
                if (propertyName == null)
                    propertyName = arrayIndex.ToString();
                value = this.ReplacerFunction.CallFromNative("stringify", holder, propertyName, value);
            }

            return value;
        }
Esempio n. 20
0
 public void PointSeries(ArrayInstance array, ColorInstance color)
 {
     int c = color.GetInt();
     fixed (byte* buf = _pixels)
     {
         for (var i = 0; i < array.Length; ++i)
         {
             Vector2f vect = GlobalPrimitives.GetVector(array[i] as ObjectInstance);
             SetPixelFast(buf, (int)vect.X, (int)vect.Y, c);
         }
     }
     _changed = true;
 }
Esempio n. 21
0
        public static void LineSeries(ArrayInstance points, ColorInstance color)
        {
            if (points == null || color == null)
                throw new NullReferenceException();

            Color sfml_col = color.GetColor();

            Vertex[] v = new Vertex[points.Length];
            for (var i = 0; i < points.Length; ++i)
            {
                ObjectInstance obj = points[i] as ObjectInstance;
                if (obj != null)
                    v[i] = new Vertex(GetVector(obj), sfml_col);
                else
                    throw new Jurassic.JavaScriptException(Program._engine, "Invalid object", "Not a JS object in array.");
            }

            Program.Batch.AddVerts(v, v.Length, PrimitiveType.Lines);
        }
Esempio n. 22
0
 // Instance constructor
 public ProcessInstance(Context context, ObjectInstance thisPrototype)
     : base(context, thisPrototype)
 {
     StartTime = DateTime.Now.Ticks;
     _Argv = Engine.Array.Construct(new object[] { "sharpjs" });
 }
Esempio n. 23
0
 public TimerHandle(Module module, FunctionInstance callback, int delay, object[] arguments, long executeAt, bool isInterval) : base(module.Engine.Object.InstancePrototype) {
     Module = module;
     Callback = callback;
     Arguments = module.Engine.Array.Construct(arguments);
     Delay = delay;
     IsInterval = isInterval;
     ExecuteAt = executeAt;
     IsUnrefd = false;
 }
        /// <summary>
        /// Serializes an array into a JSON string.
        /// </summary>
        /// <param name="value"> The array to serialize. </param>
        /// <param name="result"> The StringBuilder to write the JSON representation of the
        /// array to. </param>
        private void SerializeArray(ArrayInstance value, StringBuilder result)
        {
            // Add the spacer string to the current separator string.
            string previousSeparator = this.separator;
            this.separator += this.Indentation;

            // Check for cyclical references.
            if (this.arrayStack.Contains(value) == true)
                throw new JavaScriptException(this.engine, "TypeError", "The given object must not contain cyclical references");
            this.arrayStack.Push(value);

            result.Append('[');
            for (uint i = 0; i < value.Length; i++)
            {
                // Append the separator.
                if (i > 0)
                    result.Append(',');
                result.Append(this.separator);

                // Transform the value using the replacer function or toJSON().
                object elementValue = TransformPropertyValue(value, i);

                if (elementValue == null || elementValue == Undefined.Value || elementValue is FunctionInstance)
                {
                    // Undefined is serialized as "null".
                    result.Append("null");
                }
                else
                {
                    // Serialize the element value to the output.
                    SerializePropertyValue(elementValue, result);
                }
            }
            if (value.Length > 0)
                result.Append(previousSeparator);
            result.Append(']');

            // Remove this object from the stack.
            this.arrayStack.Pop();

            // Restore the separator to it's previous value.
            this.separator = previousSeparator;
        }
Esempio n. 25
0
 public UnwrappedArray(Marshaler marshaler, ArrayInstance array)
 {
     this.marshaler = marshaler;
     this.array = array;
 }