상속: ObjectInstance
예제 #1
0
 public string Combine(ArrayInstance pathParts)
 {
     var str = pathParts.ElementValues
         .Select(c => c.ToString())
         .ToArray();
     return System.IO.Path.Combine(str);
 }
예제 #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);
    }
예제 #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);
        }
예제 #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);
        }
예제 #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;
 }
예제 #6
0
 public void LineSeries(ArrayInstance points, ColorInstance color)
 {
     _changed = true;
 }
예제 #7
0
파일: JsHost.cs 프로젝트: Mofsy/jinxbot
        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);
            }
        }
예제 #8
0
파일: JsHost.cs 프로젝트: Mofsy/jinxbot
        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());
     }
 }
예제 #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);
 }
예제 #11
0
파일: API.cs 프로젝트: triptych/SkyOfSteel
    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 + "'");
        }
    }
예제 #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;
 }
예제 #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);
        }
예제 #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);
        }
예제 #16
0
 public void AddChat(ArrayInstance items)
 {
     _js.addChat(items);
 }
예제 #17
0
파일: API.cs 프로젝트: outrera/SkyOfSteel
    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 + "'");
        }
    }
예제 #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;
        }
예제 #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;
 }
예제 #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);
        }
예제 #22
0
 // Instance constructor
 public ProcessInstance(Context context, ObjectInstance thisPrototype)
     : base(context, thisPrototype)
 {
     StartTime = DateTime.Now.Ticks;
     _Argv = Engine.Array.Construct(new object[] { "sharpjs" });
 }
예제 #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;
        }
예제 #25
0
파일: Marshaler.cs 프로젝트: vc3/ExoWeb
 public UnwrappedArray(Marshaler marshaler, ArrayInstance array)
 {
     this.marshaler = marshaler;
     this.array = array;
 }