当前位置: 首页>>代码示例>>C#>>正文


C# StreamReader.FromJson方法代码示例

本文整理汇总了C#中System.IO.StreamReader.FromJson方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.FromJson方法的具体用法?C# StreamReader.FromJson怎么用?C# StreamReader.FromJson使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.StreamReader的用法示例。


在下文中一共展示了StreamReader.FromJson方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FixtureCreate

        public Stream FixtureCreate(Stream fixtureStream)
        {
            //Get JSON string from stream
            var fixtureJson = new StreamReader(fixtureStream).ReadToEnd();

            //Deserialize
            var contentType = HttpContext.Current.Request.ContentType;
            var fixture = fixtureJson.FromJson<Fixture>(contentType);

            //Store in Mongo DB
            var createdFixture = CreateFixture(fixture);
            createdFixture.Id = null;

            //Serialize
            var createdFixtureJson = createdFixture.ToJson();
            var createdFixtureJsonBytes = Encoding.UTF8.GetBytes(createdFixtureJson);
            var createdFixtureJsonMemoryStream = new MemoryStream(createdFixtureJsonBytes);

            return createdFixtureJsonMemoryStream;
        }
开发者ID:davidwinchurch,项目名称:DW.JSON.TypedDeserialization,代码行数:20,代码来源:InternalService.cs

示例2: FixtureCreate

        public Stream FixtureCreate(Stream fixtureStream)
        {
            //Get JSON string from stream
            var fixtureJson = new StreamReader(fixtureStream).ReadToEnd();

            //Deserialize
            var contentType = HttpContext.Current.Request.ContentType;
            var fixture = fixtureJson.FromJson<Fixture>(contentType);

            //Call Internal Service to Store
            const string fixtureCreateUrl = InternalServiceUrl + "fixture";
            var fixtureCreateJson = fixture.ToJson();
            var createdFixtureJson = RestHelper.GetJsonResponse(new Uri(fixtureCreateUrl), fixtureCreateJson, "POST", contentType);

            //Return
            var createdFixtureJsonBytes = Encoding.UTF8.GetBytes(createdFixtureJson);
            var createdFixtureJsonMemoryStream = new MemoryStream(createdFixtureJsonBytes);

            return createdFixtureJsonMemoryStream;
        }
开发者ID:davidwinchurch,项目名称:DW.JSON.TypedDeserialization,代码行数:20,代码来源:ExternalService.cs

示例3: bWebHttp_Click

        private void bWebHttp_Click(object sender, EventArgs e)
        {
            try
            {

                sw.Reset();
                sw.Start();
                
                WebRequest request = WebRequest.Create("http://localhost:8000/DesktopService/c/20");
                WebResponse ws = request.GetResponse();
                var d = new StreamReader(ws.GetResponseStream(), true).ReadToEnd().UrlDecode();
                //var s = ws.GetResponseStream().Read()
                //var s = d.Substring(1, s.Length - 2);
                var r = d.FromJson<ServiceResult>();
                var s = r.Result.ToString();
                //File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "c.txt", s);
                sw.Stop();
                box.Text += "GetData returned {0} bytes and costed {1} ms\r\n".Fmt(s.Length,
                    sw.ElapsedMilliseconds);
                byte[] bs = Convert.FromBase64String(s);
                using (MemoryStream ms = new MemoryStream(bs))
                {
                    var bmp = Image.FromStream(ms);
                    pic.Image = bmp;
                }
            }
            catch (Exception ex)
            {
                Error.Handle(ex);
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:31,代码来源:WcfForm.cs


注:本文中的System.IO.StreamReader.FromJson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。