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


C# JToken.Select方法代码示例

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


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

示例1: ParseStates

 public static List<State> ParseStates(JToken token)
 {
     if (token.Type == JTokenType.Object)
         return new List<State> {
             ParseState ((JProperty)token.First),
         };
     return token.Select (x => ParseState ((JProperty)x)).ToList ();
 }
开发者ID:Clancey,项目名称:AdobeEdgeAnimations,代码行数:8,代码来源:StageParser.cs

示例2: TransformToValue

 private static object TransformToValue(JToken jToken)
 {
     switch (jToken.Type)
     {
         case JsonTokenType.Object:
             return new DynamicJsonObject((JObject) jToken);
         case JsonTokenType.Array:
             return jToken.Select(TransformToValue).ToArray();
         default:
             return jToken.Value<object>();
     }
 }
开发者ID:torkelo,项目名称:ravendb,代码行数:12,代码来源:DynamicExpandoObject.cs

示例3: ExtractValues

        private static string[] ExtractValues(JToken json)
        {
            if (json.Type == JTokenType.String)
            {
                return new string[] { json.Value<string>() };
            }

            if (json.Type == JTokenType.Array)
            {
                return json.Select(v => v.ToString()).ToArray();
            }
            return new string[0];
        }
开发者ID:akrisiun,项目名称:dotnet-cli,代码行数:13,代码来源:PackIncludeEntry.cs

示例4: ToObject

        private static object ToObject(JToken token)
        {
            switch (token.Type)
            {
                case JTokenType.Object:
                    return token.Children<JProperty>()
                                .ToDictionary(prop => prop.Name,
                                              prop => ToObject(prop.Value));

                case JTokenType.Array:
                    return token.Select(ToObject).ToList();

                default:
                    return ((JValue)token).Value;
            }
        }
开发者ID:SolidQIT,项目名称:ABI-Compiler,代码行数:16,代码来源:JsonHelper.cs

示例5: Convert

 public JsValue Convert(JToken token)
 {
     switch (token.Type)
     {
         case JTokenType.Array:
             return Engine.Array.Construct(token.Select(Convert).ToArray());
         case JTokenType.Boolean:
             return new JsValue(token.Value<bool>());
         case JTokenType.Bytes:
             throw new NotSupportedException();
         case JTokenType.Comment:
             throw new NotSupportedException();
         case JTokenType.Constructor:
             throw new NotSupportedException();
         case JTokenType.Date:
             return Engine.Date.Construct(token.Value<DateTime>());
         case JTokenType.Float:
             return new JsValue(token.Value<float>());
         case JTokenType.Guid:
             throw new NotSupportedException();
         case JTokenType.Integer:
             return new JsValue(token.Value<int>());
         case JTokenType.None:
             throw new NotSupportedException();
         case JTokenType.Null:
             return JsValue.Null;
         case JTokenType.Object:
             return new NTSObjectInstance(Engine, (JObject)token);
         case JTokenType.Property:
             throw new NotSupportedException();
         case JTokenType.Raw:
             throw new NotSupportedException();
         case JTokenType.String:
             return new JsValue(token.Value<string>());
         case JTokenType.TimeSpan:
             throw new NotSupportedException();
         case JTokenType.Undefined:
             return JsValue.Undefined;
         case JTokenType.Uri:
             throw new NotSupportedException();
         default:
             throw new NotSupportedException();
     }
 }
开发者ID:npenin,项目名称:jint-newtonsoft.json,代码行数:44,代码来源:NTSObjectInstance.cs

示例6: TransformToValue

		private static object TransformToValue(JToken jToken)
		{
			switch (jToken.Type)
			{
				case JTokenType.Object:
					return new DynamicJsonObject((JObject) jToken);
				case JTokenType.Array:
					return jToken.Select(TransformToValue).ToArray();
				default:
					var value = jToken.Value<object>();
					if(value is long)
					{
						var l = (long) value;
						if(l > int.MinValue && int.MaxValue > l)
							return (int) l;
					}
					return value;
			}
		}
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:19,代码来源:DynamicExpandoObject.cs

示例7: CreateValue

        private static object CreateValue(JToken token)
        {
            if (token.Type == JTokenType.Array)
            {
                return token.Select(x => x.Value<string>()).ToList();
            }
            else if (token.Type == JTokenType.Object)
            {
                return token
                    .Children<JProperty>()
                    .ToDictionary(x => x.Name, x => x.Value.Value<string>());
            }
            else if (token is JValue)
            {
                var value = token.Value<string>();

                if (token.Type == JTokenType.Float)
                {
                    value = value.Replace(',', '.');
                }

                return value;
            }
            else if (token.Type == JTokenType.Null)
            {
                return null;
            }

            throw new FormatException(string.Format("Unexpected type of varspec \"{0}\"", token.Type));
        }
开发者ID:pombredanne,项目名称:uri-templates-1,代码行数:30,代码来源:TestSuite.cs

示例8: AddKeywords

 private static void AddKeywords(NodeModuleBuilder builder, JToken keywords) {
     if (keywords != null) {
         foreach (var keyword in keywords.Select(v => (string)v)) {
             builder.AddKeyword(keyword);
         }
     }
 }
开发者ID:nareshjo,项目名称:nodejstools,代码行数:7,代码来源:NpmGetCatalogCommand.cs

示例9: CreatePropertiesRecursively

 private PropertyViewModel CreatePropertiesRecursively(string name, JToken json, BuilderContext context)
 {
   if (json is JArray)
   {
     int index=0;
     ObservableCollection<ViewModel> array = new ObservableCollection<ViewModel>(json.Select(i => CreatePropertiesRecursively(string.Format("[{0}]",index++), i, context)));
     return new ArrayPropertyViewModel(this, json, name, array);
   }
   else if (json is JObject)
   {
     return new ResourcePropertyViewModel(this, json, name, new ResourceViewModel(this, (JObject)json, context));
   }
   else
     return new PropertyViewModel(this, json, name, (json != null ? json.ToString() : ""));
 }
开发者ID:paulswartz,项目名称:Mason,代码行数:15,代码来源:ResourceViewModel.cs

示例10: ConvertContentToChilds

 private static List<Metadata> ConvertContentToChilds( JToken content, IQuatrixRequest request )
 {
     return content.Select( c => {
         var mtd = c.ToObject<Metadata>();
         mtd.Request = request;
         return mtd;
     } ).ToList();
 }
开发者ID:antonmashko,项目名称:quatrix-api-csharp,代码行数:8,代码来源:FileOperations.cs

示例11: Parse

 public static StructuredText Parse(JToken json)
 {
     IList<Block> blocks = json.Select (r => ParseBlock(r)).Where(i => i != null).ToList ();
     return new StructuredText(blocks);
 }
开发者ID:benembery,项目名称:csharp-kit,代码行数:5,代码来源:StructuredText.cs

示例12: ParseTimelines

 static List<Timeline> ParseTimelines(JToken token)
 {
     if (token.Type == JTokenType.Object)
         return new List<Timeline> {
             ParseTimeline ((JProperty)token.First),
         };
     return token.Select (x => ParseTimeline ((JProperty)x)).ToList ();
 }
开发者ID:Clancey,项目名称:AdobeEdgeAnimations,代码行数:8,代码来源:StageParser.cs

示例13: TransformToValue

 private static object TransformToValue(JToken jToken)
 {
     switch (jToken.Type)
     {
         case JTokenType.Object:
             return new DynamicJsonObject((JObject) jToken);
         case JTokenType.Array:
             return jToken.Select(TransformToValue).ToArray();
         default:
             var value = jToken.Value<object>();
             if(value is long)
             {
                 var l = (long) value;
                 if(l > int.MinValue && int.MaxValue > l)
                     return (int) l;
             }
             var str = value as string;
             if(str != null && str.StartsWith("0x"))
             {
                 return JsonLuceneNumberConverter.ParseNumber(str);
             }
             return value;
     }
 }
开发者ID:kenegozi,项目名称:ravendb,代码行数:24,代码来源:DynamicExpandoObject.cs

示例14: PreencherListaStatements

 /// <summary>
 /// Cria o nó Body do Program
 /// </summary>
 /// <param name="jToken"></param>
 /// <returns></returns>
 private List<Statement> PreencherListaStatements(JToken jToken)
 {
     return jToken.Select(PreencherStatement).ToList();
 }
开发者ID:ffarzat,项目名称:ConsoleComV8,代码行数:9,代码来源:Fabrica.cs

示例15: ConvertTokenToDynamic

        protected dynamic ConvertTokenToDynamic(JToken token)
        {
            // Strong types
            if (token.Type == JTokenType.String) {
                return (string)token;
            }
            if (token is JValue) {
                return ((JValue)token).Value;
            }
            // Full object
            if (token is JObject) {
                var expando = new ExpandoObject();
                var childTokens = (
                    from childToken in token
                    where childToken is JProperty
                    select childToken as JProperty
                    ).ToList();

                foreach (var property in childTokens) {
                    var value = ConvertTokenToDynamic(property.Value);
                    ((IDictionary<string, object>)expando).Add(property.Name, value);
                }
                return expando;
            }
            // Array of properties possible?
            // @TODO: Check if needed
            if (token is JArray) {
                return token.Select(arrayItem => ConvertTokenToDynamic(arrayItem)).ToList();
            }

            throw new ArgumentException(string.Format("Unknown token type '{0}'", token.GetType()), "token");
        }
开发者ID:GodLesZ,项目名称:ZeusEngine,代码行数:32,代码来源:JsonSerializationProtocol.cs


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