protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "application/json";

            string programID = Request.QueryString["programID"];
            string recordOption = Request.QueryString["option"];
            bool success;

            if (User.IsInRole("recorder"))
            {
                success = uWiMP.TVServer.Recordings.RecordProgramById(Convert.ToInt32(programID), (Recordings.RecordingType)Convert.ToInt32(recordOption));
            }
            else
            {
                success = false;
            }

            using (JsonTextWriter jw = new JsonTextWriter())
            {
                jw.PrettyPrint = true;
                jw.WriteStartObject();
                jw.WriteMember("result");
                jw.WriteBoolean(success);
                jw.WriteEndObject();

                Response.Write(jw.ToString());
            }
        }
        static internal string ConvertRequestToJson(uWiMP.TVServer.MPClient.Request request)
        {
            JsonTextWriter jw = new JsonTextWriter();
            jw.PrettyPrint = true;
            jw.WriteStartObject();
            jw.WriteMember("action");
            jw.WriteString(request.Action);
            jw.WriteMember("filter");
            jw.WriteString(request.Filter);
            jw.WriteMember("value");
            jw.WriteString(request.Value);
            jw.WriteMember("start");
            jw.WriteString(request.Start.ToString());
            jw.WriteMember("pagesize");
            jw.WriteString(request.PageSize.ToString());
            jw.WriteMember("shuffle");
            jw.WriteBoolean(request.Shuffle);
            jw.WriteMember("enqueue");
            jw.WriteBoolean(request.Enqueue);
            jw.WriteMember("tracks");
            jw.WriteString(request.Tracks);
            jw.WriteEndObject();

            return jw.ToString();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Response.ContentType = "application/json";

            string programID = Request.QueryString["programID"];
            Program program = uWiMP.TVServer.Programs.GetProgramByProgramId(Convert.ToInt32(programID));
            Channel channel = uWiMP.TVServer.Channels.GetChannelByChannelId(program.IdChannel);

            string timetext = string.Format("<b>{0}-{1}</b><br>", program.StartTime.ToShortTimeString(), program.EndTime.ToShortTimeString());
            string title = program.Title == "" ? GetGlobalResourceObject("uWiMPStrings", "unknown_title").ToString() : program.Title;
            string episodeName = program.EpisodeName == "" ? timetext : timetext + "<b>" + program.EpisodeName + "</b><br>";
            string description = program.Description == "" ? GetGlobalResourceObject("uWiMPStrings", "description_not_found").ToString() : episodeName + program.Description;

            using (JsonTextWriter jw = new JsonTextWriter())
            {
                jw.PrettyPrint = true;
                jw.WriteStartObject();
                jw.WriteMember("title");
                jw.WriteString(title);
                jw.WriteMember("description");
                jw.WriteString(description);
                jw.WriteMember("channel");
                jw.WriteString(channel.DisplayName);
                jw.WriteMember("running");
                jw.WriteBoolean(program.IsRunningAt(DateTime.Now));
                jw.WriteMember("scheduled");
                jw.WriteBoolean(uWiMP.TVServer.Schedules.IsProgramScheduled(program));
                jw.WriteEndObject();

                Response.Write(jw.ToString());
            }
        }
Beispiel #4
0
        public void Complex()
        {
            const string input = @"{'menu': {
                'header': 'SVG Viewer',
                'items': [
                    {'id': 'Open'},
                    {'id': 'OpenNew', 'label': 'Open New'},
                    null,
                    {'id': 'ZoomIn', 'label': 'Zoom In'},
                    {'id': 'ZoomOut', 'label': 'Zoom Out'},
                    {'id': 'OriginalView', 'label': 'Original View'},
                    null,
                    {'id': 'Quality'},
                    {'id': 'Pause'},
                    {'id': 'Mute'},
                    null,
                    {'id': 'Find', 'label': 'Find...'},
                    {'id': 'FindAgain', 'label': 'Find Again'},
                    {'id': 'Copy'},
                    {'id': 'CopyAgain', 'label': 'Copy Again'},
                    {'id': 'CopySVG', 'label': 'Copy SVG'},
                    {'id': 'ViewSVG', 'label': 'View SVG'},
                    {'id': 'ViewSource', 'label': 'View Source'},
                    {'id': 'SaveAs', 'label': 'Save As'},
                    null,
                    {'id': 'Help'},
                    {'id': 'About', 'label': 'About Adobe CVG Viewer...'}
                ]
            }}";

            JsonTextReader reader = new JsonTextReader(new StringReader(input));
            JsonTextWriter writer = new JsonTextWriter();
            JsonRecorder.Record(reader).Playback(writer);
            Assert.AreEqual("{\"menu\":{\"header\":\"SVG Viewer\",\"items\":[{\"id\":\"Open\"},{\"id\":\"OpenNew\",\"label\":\"Open New\"},null,{\"id\":\"ZoomIn\",\"label\":\"Zoom In\"},{\"id\":\"ZoomOut\",\"label\":\"Zoom Out\"},{\"id\":\"OriginalView\",\"label\":\"Original View\"},null,{\"id\":\"Quality\"},{\"id\":\"Pause\"},{\"id\":\"Mute\"},null,{\"id\":\"Find\",\"label\":\"Find...\"},{\"id\":\"FindAgain\",\"label\":\"Find Again\"},{\"id\":\"Copy\"},{\"id\":\"CopyAgain\",\"label\":\"Copy Again\"},{\"id\":\"CopySVG\",\"label\":\"Copy SVG\"},{\"id\":\"ViewSVG\",\"label\":\"View SVG\"},{\"id\":\"ViewSource\",\"label\":\"View Source\"},{\"id\":\"SaveAs\",\"label\":\"Save As\"},null,{\"id\":\"Help\"},{\"id\":\"About\",\"label\":\"About Adobe CVG Viewer...\"}]}}", writer.ToString());
        }
 public void String()
 {
     JsonRecorder recorder = new JsonRecorder();
     recorder.WriteString("Hello World");
     JsonTextWriter writer = new JsonTextWriter();
     recorder.Playback(writer);
     Assert.AreEqual("\"Hello World\"", writer.ToString());
 }
Beispiel #6
0
        public static void JayrockWriterObjects ()
        {
            for (int j = 0; j < Common.Iterations; j++) {
                StringBuilder output = new StringBuilder ();
                JsonWriter writer = new JsonTextWriter (new StringWriter (output));

                int n = Common.SampleObject.Length;
                for (int i = 0; i < n; i += 2) {
                    switch ((char) Common.SampleObject[i]) {
                    case '{':
                        writer.WriteStartObject ();
                        break;

                    case '}':
                        writer.WriteEndObject ();
                        break;

                    case '[':
                        writer.WriteStartArray ();
                        break;

                    case ']':
                        writer.WriteEndArray ();
                        break;

                    case 'P':
                        writer.WriteMember (
                            (string) Common.SampleObject[i + 1]);
                        break;

                    case 'I':
                        writer.WriteNumber (
                            (int) Common.SampleObject[i + 1]);
                        break;

                    case 'D':
                        writer.WriteNumber (
                            (double) Common.SampleObject[i + 1]);
                        break;

                    case 'S':
                        writer.WriteString (
                            (string) Common.SampleObject[i + 1]);
                        break;

                    case 'B':
                        writer.WriteBoolean (
                            (bool) Common.SampleObject[i + 1]);
                        break;

                    case 'N':
                        writer.WriteNull ();
                        break;
                    }
                }
            }
        }
Beispiel #7
0
        public static void Write(Geometry geometry, TextWriter writer)
        {
            if (geometry == null)
                return;
            if (writer == null)
                throw new ArgumentNullException("writer", "A valid text writer object is required.");

            JsonTextWriter jwriter = new JsonTextWriter(writer);
            Write(geometry, jwriter);
        }
 public void WriteBoolean()
 {
     JsonTextWriter writer = new JsonTextWriter(new StringWriter());
     writer.WriteBoolean(true);
     Assert.AreEqual("true", writer.ToString());
     
     writer = new JsonTextWriter(new StringWriter());
     writer.WriteBoolean(false);
     Assert.AreEqual("false", writer.ToString());
 }
        static internal string ReturnBoolean(bool value)
        {
            JsonTextWriter jw = new JsonTextWriter();
            jw.PrettyPrint = true;
            jw.WriteStartObject();
            jw.WriteMember("result");
            jw.WriteBoolean(value);
            jw.WriteEndObject();

            return jw.ToString();
        }
Beispiel #10
0
        public static void Write(Coordinate coordinate, JsonTextWriter jwriter)
        {
            if (coordinate == null)
                return;
            if (jwriter == null)
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");

            jwriter.WriteStartArray();
            jwriter.WriteNumber(coordinate.X);
            jwriter.WriteNumber(coordinate.Y);
            if (!double.IsNaN(coordinate.Z))
                jwriter.WriteNumber(coordinate.Z);
            jwriter.WriteEndArray();
        }
Beispiel #11
0
        private static void PrettyColorPrint(string path, TextWriter output, JsonPalette palette) 
        {
            Debug.Assert(output != null);

            using (TextReader input = path.Equals("-") ? Console.In : new StreamReader(path))
            using (JsonTextReader reader = new JsonTextReader(input))
            using (JsonTextWriter writer = new JsonTextWriter(output))
            {
                writer.PrettyPrint = true;
                JsonColorWriter colorWriter = new JsonColorWriter(writer, palette);
                colorWriter.WriteFromReader(reader);
                output.WriteLine();
            }
        }
Beispiel #12
0
        public static string PretifyJson(this string text)
        {
            var input = new StringReader(text);
            var output = new StringWriter();

            using (var reader = new JsonTextReader(input))
            using (var writer = new JsonTextWriter(output))
            {

                writer.PrettyPrint = true;
                writer.WriteFromReader(reader);
            }

            return output.ToString();
        }
Beispiel #13
0
    public string GetUserUnitRelations(string userId, string type)
    {
        cPos.Model.LoggingSessionInfo loggingSessionInfo = new cPos.Model.LoggingSessionInfo();
        var customerService = new CustomerService();

        CustomerUserInfo user = new CustomerUserInfo();

        user = customerService.GetCustomerUserInfoByMobileUser(userId);

        string content = string.Empty;

        Jayrock.Json.JsonTextWriter writer = new Jayrock.Json.JsonTextWriter();
        Jayrock.Json.Conversion.JsonConvert.Export(user, writer);
        content = writer.ToString();
        return(content);
    }
Beispiel #14
0
        public static void JayrockWriterNumbers ()
        {
            for (int i = 0; i < Common.Iterations; i++) {
                StringBuilder output = new StringBuilder ();
                JsonWriter writer = new JsonTextWriter (new StringWriter (output));

                writer.WriteStartArray ();

                foreach (int n in Common.SampleInts)
                    writer.WriteNumber (n);

                foreach (double n in Common.SampleDoubles)
                    writer.WriteNumber (n);

                writer.WriteEndArray ();
            }
        }
Beispiel #15
0
        public void StoreText(string url, string text, DateTime lastModified)
        {
            string file_path = Path.Combine(storage_dir, Common.MD5(url));

            using (TextWriter tw = File.CreateText(file_path))
            {
                using (Jayrock.Json.JsonTextWriter jtw = new Jayrock.Json.JsonTextWriter(tw))
                {
                    jtw.WriteStartObject();
                    jtw.WriteMember("LastModified");
                    jtw.WriteString(datetime_tostring(lastModified));

                    jtw.WriteMember("Text");
                    jtw.WriteString(text);

                    jtw.WriteEndObject();
                }
            }
        }
Beispiel #16
0
 private static string objectToJson(object obj)
 {
     if (obj is System.ValueType || obj is string)//认为是值类型
     {
         if (obj != null)
         {
             return(obj.ToString());
         }
         else
         {
             return("");
         }
     }
     else
     {
         Jayrock.Json.JsonTextWriter writer = new Jayrock.Json.JsonTextWriter();
         Jayrock.Json.Conversion.JsonConvert.Export(enableJson(obj), writer);
         string str = writer.ToString();
         return(str);
     }
 }
Beispiel #17
0
 public void PrettyPrinting()
 {
     JsonTextWriter writer = new JsonTextWriter();
     writer.PrettyPrint = true;
     writer.WriteFromReader(new JsonTextReader(new StringReader("{'menu':{'id':'file','value':'File:','popup':{'menuitem':[{'value':'New','onclick':'CreateNewDoc()'},{'value':'Open','onclick':'OpenDoc()'},{'value':'Close','onclick':'CloseDoc()'}]}}}")));
     Assert.AreEqual(RewriteLines(@"{
     ""menu"": {
     ""id"": ""file"",
     ""value"": ""File:"",
     ""popup"": {
     ""menuitem"": [ {
         ""value"": ""New"",
         ""onclick"": ""CreateNewDoc()""
     }, {
         ""value"": ""Open"",
         ""onclick"": ""OpenDoc()""
     }, {
         ""value"": ""Close"",
         ""onclick"": ""CloseDoc()""
     } ]
     }
     }
     }"), writer.ToString() + Environment.NewLine);
 }
Beispiel #18
0
        public static void Write(Geometry geometry, JsonTextWriter jwriter)
        {
            if (geometry == null)
                return;
            if (jwriter == null)
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");

            if (geometry is Point)
            {
                Write(geometry as Point, jwriter);
            }
            else if (geometry is LineString)
            {
                Write(geometry as LineString, jwriter);
            }
            else if (geometry is Polygon)
            {
                Write(geometry as Polygon, jwriter);
            }
            else if (geometry is MultiPoint)
            {
                Write(geometry as MultiPoint, jwriter);
            }
            else if (geometry is MultiLineString)
            {
                Write(geometry as MultiLineString, jwriter);
            }
            else if (geometry is MultiPolygon)
            {
                Write(geometry as MultiPolygon, jwriter);
            }
            else if (geometry is GeometryCollection)
            {
                Write(geometry as GeometryCollection, jwriter);
            }
        }
        protected override void ProcessRequest()
        {
            string httpMethod = Request.RequestType;

            if (!CaselessString.Equals(httpMethod, "GET") &&
                !CaselessString.Equals(httpMethod, "HEAD"))
            {
                throw new JsonRpcException(string.Format("HTTP {0} is not supported for RPC execution. Use HTTP GET or HEAD only.", httpMethod));
            }

            string callback = Mask.NullString(Request.QueryString["jsonp"]);
            bool padded = callback.Length > 0;
            
            //
            // The response type depends on whether JSONP (JSON with 
            // Padding) is in effect or not.
            //

            Response.ContentType = padded ? "text/javascript" : "application/json";
            
            //
            // Validate that the JSONP callback method conforms to the 
            // allowed syntax. If not, issue a client-side exception
            // that will certainly help to bring problem to light, even if
            // a little too aggressively.
            //
            
            if (padded)
            {
                if (!_jsonpex.IsMatch(callback))
                {
                    Response.Write("throw new Error('Invalid JSONP callback parameter value.');");
                    Response.End();
                }
            }
            
            //
            // Convert the query string into a call object.
            //

            JsonWriter writer = new JsonTextWriter();
            
            writer.WriteStartObject();
            
            writer.WriteMember("id");
            writer.WriteNumber(-1);
            
            writer.WriteMember("method");
            
            string methodName = Mask.NullString(Request.PathInfo);
            
            if (methodName.Length == 0)
            {
                writer.WriteNull();
            }
            else
            {
                //
                // If the method name contains periods then we replace it
                // with dashes to mean the one and same thing. This is
                // done to provide dashes as an alternative to some periods
                // since some web servers may block requests (for security
                // reasons) if a path component of the URL contains more
                // than one period.
                //
                
                writer.WriteString(methodName.Substring(1).Replace('-', '.'));
            }
            
            writer.WriteMember("params");
            NameValueCollection query = new NameValueCollection(Request.QueryString);
            query.Remove(string.Empty);
            JsonConvert.Export(Request.QueryString, writer);
            
            writer.WriteEndObject();
            
            //
            // Delegate rest of the work to JsonRpcDispatcher.
            //

            JsonRpcDispatcher dispatcher = new JsonRpcDispatcher(Service);
            using (new JsonRpcDispatchScope(dispatcher, Context))
            {
                dispatcher.RequireIdempotency = true;

                if (padded)
                {
                    //
                    // For JSONP, see details here:
                    // http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/
                    //

                    Response.Write(callback);
                    Response.Write('(');
                }

                dispatcher.Process(new StringReader(writer.ToString()), Response.Output);

                if (padded)
                    Response.Write(')');
            }
        }
Beispiel #20
0
 private JsonWriter CreateJsonWriter(TextWriter @out)
 {
     var jsonWriter = new JsonTextWriter(@out) { PrettyPrint = true };
     return jsonWriter;
 }
        public JsonTextWriter Request(string method, params string [] list)
        {
            JsonTextWriter writer = new JsonTextWriter();

            writer.WriteStartObject ();
            writer.WriteMember ("jsonrpc");
            writer.WriteString ("2.0");
            writer.WriteMember ("id");
            writer.WriteString ("1");
            writer.WriteMember ("method");
            writer.WriteString (method);
            writer.WriteMember ("params");
            writer.WriteStartArray ();

            foreach (string param in list)
                writer.WriteString (param);

            return writer;
        }
        // Return error code
        public int Post(string url, JsonTextWriter json)
        {
            WebRequest request = WebRequest.Create (serverURL+url);

              request.Method = "POST";

            json.AutoComplete();

            string text = json.ToString();

            Log.Write("Request: ");
            Log.WriteLine (text.ToString()+"\n");

            json.Close();

              byte[] postdata = System.Text.Encoding.ASCII.GetBytes (text);

            request.ContentLength = postdata.Length;

            // Wait one second when 60th RPC call is made during minute
            if (Interlocked.Read(ref throttle) == 60)
            {
                if (onMessage != null && severity >= 6)
                    onMessage(this,"[{0}] Throttling...", DateTime.Now);
                while (Interlocked.Read(ref throttle) == 60)
                    Thread.Sleep(1000);
            }

            if (timer.Enabled) Interlocked.Increment(ref throttle);

            try {
                Stream stream = request.GetRequestStream ();

              	stream.Write (postdata, 0, postdata.Length);
              	stream.Close ();
            } catch (System.Net.WebException ex) {
                if (onMessage != null && severity >= 3) onMessage(this,ex.Message);
                return -1;
            }

            if (onMessage != null && severity >= 7)
                onMessage(this,"\n[{0}] Connecting...",DateTime.Now);

            try {
              	WebResponse response = request.GetResponse ();
                ProcessResponse(response);
                if (onServerStatus != null) onServerStatus(this,new ServerStatusEventArgs());
            } catch (System.Net.WebException ex) {
                if (Regex.IsMatch(ex.Response.ContentType,"json-rpc")) {
                  WebResponse response = ex.Response;
                    ProcessResponse(response);
                    ServerErrorEventArgs args =
                        new ServerErrorEventArgs(r.error.code,r.error.data,r.error.message);
                    if (onServerError != null) onServerError(this,args);
                    return r.error.code;
                } else {
                    if (onMessage != null && severity >= 3) onMessage(this,ex.Message);
                    return -1;
                }
            }
            return 0;
        }
        public void AddHashedParameters(JsonTextWriter writer, params string [] list)
        {
            if ( list.Length % 2 > 0) return;

            writer.WriteStartObject ();

            for (int i = 0; i < list.Length; i+=2)
            {
                writer.WriteMember (list[i]);
                writer.WriteString (list[i+1]);
            }

            writer.WriteEndObject ();
        }
Beispiel #24
0
 private static JsonWriter CreateJsonWriter(TextWriter writer)
 {
     JsonTextWriter jsonWriter = new JsonTextWriter(writer);
     jsonWriter.PrettyPrint = true;
     return jsonWriter;
 }
        public int SubscribeDailyGroupStatistics()
        {
            int nReqID = GetUniqueReqID();

            foreach (int groupId in m_groupIds)
            {
                Jayrock.Json.JsonTextWriter jsonWriter = new Jayrock.Json.JsonTextWriter();
                jsonWriter.WriteStartObject();
                jsonWriter.WriteMember("version");
                jsonWriter.WriteNumber(1);
                jsonWriter.WriteMember("topic");
                jsonWriter.WriteString("contact-center");
                jsonWriter.WriteMember("request-id");
                jsonWriter.WriteNumber(nReqID);
                jsonWriter.WriteMember("message");
                jsonWriter.WriteString("subscribe-events");
                jsonWriter.WriteMember("subscribe");
                jsonWriter.WriteStartArray();
                jsonWriter.WriteStartArray();
                jsonWriter.WriteString("ecc");
                jsonWriter.WriteString("daily-group-stats");
                jsonWriter.WriteStartArray();
                jsonWriter.WriteString(groupId.ToString());
                jsonWriter.WriteEndArray();
                jsonWriter.WriteEndArray();
                jsonWriter.WriteEndArray();
                jsonWriter.WriteEndObject();

                if (!SendRequest(jsonWriter.ToString()))
                    return -1;
            }
            return nReqID;
        }
Beispiel #26
0
        public static void Write(IGISLayer features, TextWriter writer)
        {
            if (features == null)
                return;
            if (writer == null)
                throw new ArgumentNullException("writer", "A valid text writer object is required.");

            JsonTextWriter jwriter = new JsonTextWriter(writer);
            Write(features, jwriter);
        }
        protected virtual void WriteResponse(object response, TextWriter output)
        {
            if (response == null)
                throw new ArgumentNullException("response");

            if (output == null)
                throw new ArgumentNullException("output");

            JsonWriter writer = (JsonWriter) _serviceProvider.GetService(typeof(JsonWriter));

            if (writer == null)
                writer = new JsonTextWriter(output);

            ExportContext exportContext = new ExportContext();
            exportContext.Export(response, writer);
        }
Beispiel #28
0
 public static string GetJsonString(object obj)
 {
     Jayrock.Json.JsonTextWriter writer = new Jayrock.Json.JsonTextWriter();
     Jayrock.Json.Conversion.JsonConvert.Export(obj, writer);
     return(writer.ToString());
 }
Beispiel #29
0
 public void ToJSON(Jayrock.Json.JsonTextWriter jwriter)
 {
     GeoJSONWriter.Write(this, jwriter, _nonSerializedFields);
 }
Beispiel #30
0
        public static void Write(Coordinate[] coordinates, JsonTextWriter jwriter)
        {
            if (coordinates == null)
                return;
            if (jwriter == null)
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");

            jwriter.WriteStartArray();

            foreach (Coordinate entry in coordinates)
            {
                Write(entry, jwriter);
            }
            jwriter.WriteEndArray();
        }
Beispiel #31
0
        public void Blank()
        {
            JsonTextWriter writer = new JsonTextWriter(new StringWriter());

            Assert.AreEqual(string.Empty, writer.ToString());
        }
        internal bool Authenticate()
        {
            Jayrock.Json.JsonTextWriter jsonWriter = new Jayrock.Json.JsonTextWriter();
            jsonWriter.WriteStartObject();
            jsonWriter.WriteMember("version");
            jsonWriter.WriteNumber(1);
            jsonWriter.WriteMember("topic");
            jsonWriter.WriteString("contact-center");
            jsonWriter.WriteMember("request-id");
            jsonWriter.WriteNumber(GetUniqueReqID());
            jsonWriter.WriteMember("message");
            jsonWriter.WriteString("authenticate");
            jsonWriter.WriteMember("user");
            jsonWriter.WriteString(strAdapterUserName);
            jsonWriter.WriteMember("password");
            jsonWriter.WriteString(strAdapterPassword);
            jsonWriter.WriteEndObject();

            if (!SendRequest(jsonWriter.ToString()))
                return false;

            return ReceiveResponse("authenticate");
        }
Beispiel #33
0
 public void ToJSON(Jayrock.Json.JsonTextWriter jwriter)
 {
     GeoJSONWriter.Write(this, jwriter);
 }
Beispiel #34
0
        public String Send(TransportMessage message)
        {
            StringBuilder buffer = new StringBuilder();
              JsonWriter writer = new JsonTextWriter(new StringWriter(buffer));

              lock (exportLock)
            JsonExportContext.Export(message, writer);

              String json = buffer.ToString();

              socket.Send(json);
              return json;
        }
Beispiel #35
0
        public static void Write(Coordinate coordinate, TextWriter writer)
        {
            if (coordinate == null)
                return;
            if (writer == null)
                throw new ArgumentNullException("writer", "A valid text writer object is required.");

            JsonTextWriter jwriter = new JsonTextWriter(writer);
            Write(coordinate, jwriter);
        }
Beispiel #36
0
 /// <summary>
 /// Overridden to return a JSON formatted object as a string.
 /// </summary>
 
 public override string ToString()
 {
     JsonTextWriter writer = new JsonTextWriter();
     Format(writer);
     return writer.ToString();
 }
Beispiel #37
0
        public static void Write(IGISLayer features, JsonTextWriter jwriter)
        {
            if (features == null)
                return;
            if (jwriter == null)
                throw new ArgumentNullException("jwriter", "A valid JSON writer object is required.");

            jwriter.WriteStartObject();

                jwriter.WriteMember("type");
                jwriter.WriteString("FeatureCollection");

                jwriter.WriteMember("features");
                jwriter.WriteStartArray();

                    while (features.MoveNext())
                    {
                        Write(features.Current, jwriter);
                    }

                jwriter.WriteEndArray();

            jwriter.WriteEndObject();
        }