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


C# JContainer类代码示例

本文整理汇总了C#中JContainer的典型用法代码示例。如果您正苦于以下问题:C# JContainer类的具体用法?C# JContainer怎么用?C# JContainer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Serialize

 public static byte[] Serialize(JContainer item)
 {
     var stringWriter = new StringWriter();
     var writer = new JsonTextWriter(stringWriter);
     item.WriteTo(writer);
     return Encoding.UTF8.GetBytes(stringWriter.ToString());
 }
开发者ID:bmjames,项目名称:diffa-dotnet,代码行数:7,代码来源:JsonAmqpRpcServer.cs

示例2: FillWithJsonObject

 public void FillWithJsonObject(JContainer dict, Scheme scheme)
 {
     Title = (string)dict["title"];
     Id = (string)dict["id"];
     Color = (Color)ColorConverter.ConvertFromString((string)dict["color"]);
     Points = (dict["points"]).Select(p => new Point((double)p[0], (double)p[1])).ToArray();
 }
开发者ID:baSSiLL,项目名称:SchemeEditorWpf,代码行数:7,代码来源:Room.cs

示例3: JTokenWriter

        /// <summary>
        /// Initializes a new instance of the <see cref="JTokenWriter"/> class writing to the given <see cref="JContainer"/>.
        /// </summary>
        /// <param name="container">The container being written to.</param>
        public JTokenWriter(JContainer container)
        {
            ValidationUtils.ArgumentNotNull(container, "container");

            _token = container;
            _parent = container;
        }
开发者ID:GOArango,项目名称:arangoclient.net,代码行数:11,代码来源:JTokenWriter.cs

示例4: AddParent

 private void AddParent(JContainer container)
 {
   if (this._parent == null)
     this._token = container;
   else
     this._parent.AddAndSkipParentCheck((JToken) container);
   this._parent = container;
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:8,代码来源:JTokenWriter.cs

示例5: FillWithJsonObject

 public virtual void FillWithJsonObject(JContainer dict, Scheme scheme)
 {
     Title = (string)dict["title"];
     Room = scheme.Rooms.Single(r => r.Id.Equals(dict["room"]));
     QRCode = (string)dict[@"qr_code"];
     Image = (string)dict["image"];
     Visible = (bool)dict[@"visible"];
 }
开发者ID:baSSiLL,项目名称:SchemeEditorWpf,代码行数:8,代码来源:Item.cs

示例6: _SendHttpRequest

        /**
         * @param uri
         * @param method Case-insensitive
         * @param bodyObject
         * @param responseObject output, the value would be JObject or JArray
         */
        private bool _SendHttpRequest(string uri, string method, JObject bodyObject, out JContainer responseObject)
        {
            responseObject = null;
            var url = APIEndPoint + BaseURL + @"/" + uri;

            // Set remote url and http method.
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
            request.Method = method;

            // Set the content type header and http body.
            if(bodyObject != null){
                var body = JsonConvert.SerializeObject(bodyObject);
                if (body.Length != 0)
                {
                    request.ContentType = "application/json";
                    using (Stream requestStream = request.GetRequestStream())
                    using (StreamWriter writer = new StreamWriter(requestStream))
                    {
                        writer.Write(body);
                    }
                }
            }

            // Set the authorization id.
            string sAuth = "auth_id=" + AuthoId;
            request.Headers.Add("Authorization", sAuth);

            string responseData = "";
            try
            {
                // Send request
                System.Net.WebResponse response = (HttpWebResponse)request.GetResponse();
                responseData = new StreamReader(response.GetResponseStream()).ReadToEnd();

            }
            catch (WebException e)
            {
                HttpWebResponse response = (HttpWebResponse)e.Response;
                if (response != null)
                {
                    responseData = new StreamReader(response.GetResponseStream()).ReadToEnd();

                    response.Close();   // Releases the resources of the response.
                }
            }
            catch (Exception)
            {
                return false;
            }

            if (!string.IsNullOrEmpty(responseData))
            {
                var res = JsonConvert.DeserializeObject(responseData);
                responseObject = res as JContainer;
            }

            return true;
        }
开发者ID:JeffreyZksun,项目名称:RESTCSharp,代码行数:64,代码来源:RestAPI.cs

示例7: AddParent

    private void AddParent(JContainer container)
    {
      if (_parent == null)
        _token = container;
      else
        _parent.Add(container);

      _parent = container;
    }
开发者ID:gabrielamboss,项目名称:Ulkoa,代码行数:9,代码来源:JTokenWriter.cs

示例8: FromJObject

 public static QueryAggregateDigestsRequest FromJObject(JContainer jObject)
 {
     var request = JsonConvert.DeserializeObject<QueryAggregateDigestsRequest>(jObject.ToString());
     if (request.Constraints == null || request.Buckets == null)
     {
         throw new ArgumentNullException();
     }
     return request;
 }
开发者ID:bmjames,项目名称:diffa-dotnet,代码行数:9,代码来源:QueryAggregateDigestsRequest.cs

示例9: FormatLinks

 public void FormatLinks(JContainer container, IEnumerable<Link> links, JsonSerializer serializer)
 {
     var jLinks = new JArray();
     foreach (var link in links)
     {
         jLinks.Add(JObject.FromObject(link, serializer));
     }
     container[_linksPropertyName] = jLinks;
 }
开发者ID:muratbeyaztas,项目名称:Simple.Web,代码行数:9,代码来源:DefaultJsonLinksFormatter.cs

示例10: FormatLinks

 public void FormatLinks(JContainer container, IEnumerable<Link> links, JsonSerializer serializer)
 {
     var jLinks = new JObject();
     foreach (var link in links)
     {
         jLinks[link.Rel] = JValue.CreateString(link.Href);
     }
     container[_linksPropertyName] = jLinks;
 }
开发者ID:muratbeyaztas,项目名称:Simple.Web,代码行数:9,代码来源:SimpleJsonLinksFormatter.cs

示例11: AssertSchemaIsValid

        public static void AssertSchemaIsValid(JSchema jSchema, JContainer jContainer)
        {
            IList<string> messages;
            var isValid = jContainer.IsValid(jSchema, out messages);
            foreach (var message in messages)
            {
                Console.WriteLine(message);
            }

            Assert.IsTrue(isValid);
        }
开发者ID:baLR0n,项目名称:HaloSharp,代码行数:11,代码来源:SchemaUtility.cs

示例12: parseActions

 /// <summary>
 /// Parse the child Actions object that is part of the Tropo Result object. 
 /// </summary>
 /// <param name="actions">Actions - is either an Object or an Array.</param>
 /// <returns></returns>
 public static JContainer parseActions(JContainer actions)
 {
     JTokenType type = actions.Type;
     if (type == JTokenType.Array)
     {
         return JArray.Parse(actions.ToString());
     }
     else
     {
         return parseObject(actions);
     }
 }
开发者ID:Shannon-McCoy,项目名称:tropo-webapi-csharp,代码行数:17,代码来源:TropoUtilities.cs

示例13: ReadInto

 private bool ReadInto(JContainer c)
 {
     JToken firstChild = c.First;
       if (firstChild == null)
       {
     return SetEnd(c);
       }
       else
       {
     SetToken(firstChild);
     _current = firstChild;
     _parent = c;
     return true;
       }
 }
开发者ID:robgreen,项目名称:nom,代码行数:15,代码来源:JsonTokenReader.cs

示例14: GetEndToken

 private JsonToken? GetEndToken(JContainer c)
 {
     switch (c.Type)
       {
     case JsonTokenType.Object:
       return JsonToken.EndObject;
     case JsonTokenType.Array:
       return JsonToken.EndArray;
     case JsonTokenType.Constructor:
       return JsonToken.EndConstructor;
     case JsonTokenType.Property:
       return null;
     default:
       throw MiscellaneousUtils.CreateArgumentOutOfRangeException("Type", c.Type, "Unexpected JContainer type.");
       }
 }
开发者ID:robgreen,项目名称:nom,代码行数:16,代码来源:JsonTokenReader.cs

示例15: GeneratePatterns

        /// <summary>
        /// Generates a collection of patterns for the specified <see cref="JContainer"/>.
        /// </summary>
        public PatternCollection GeneratePatterns(JContainer root, int desiredCount, bool skipValues = true)
        {
            var descendants = root.DescendantsAndSelf().ToArray();
            descendants.Shuffle(random);

            if (skipValues)
                descendants = descendants.Where(x => x is JObject || x is JArray).ToArray();

            var patterns = descendants
                .Select(x => x.Path)
                .Where(x => !string.IsNullOrWhiteSpace(x))
                .Take(desiredCount)
                .Select(x => (random.NextBool() ? "!" : "") + x)
                .Select(AddWildcards)
                .ToArray();

            return PatternCollection.Parse(patterns);
        }
开发者ID:pgolebiowski,项目名称:onism-cldr,代码行数:21,代码来源:PatternCollectionGenerator.cs


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