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


C# RavenJToken类代码示例

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


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

示例1: AddParent

		private void AddParent(RavenJToken token)
		{
			if (_token == null)
			{
				_token = token;
				_tokenStack.Push(_token);
				return;
			}

			switch (CurrentToken.Type)
			{
				case JTokenType.Object:
					if (string.IsNullOrEmpty(_tempPropName))
						throw new JsonWriterException("Unexpected object token");
					((RavenJObject)CurrentToken)[_tempPropName] = token;
					_tempPropName = null;
					break;
				case JTokenType.Array:
					if (!string.IsNullOrEmpty(_tempPropName))
						throw new JsonWriterException("Unexpected property token");
					((RavenJArray)CurrentToken).Add(token);
					break;
				default:
					throw new JsonWriterException("Unexpected token: " + CurrentToken.Type);
			}

			_tokenStack.Push(token);
		}
开发者ID:alwin,项目名称:ravendb,代码行数:28,代码来源:RavenJTokenWriter.cs

示例2: StripQuotesIfNeeded

		private static string StripQuotesIfNeeded(RavenJToken value)
		{
			var str = value.ToString(Formatting.None);
			if (str.StartsWith("\"") && str.EndsWith("\""))
				return str.Substring(1, str.Length - 2);
			return str;
		}
开发者ID:robashton,项目名称:ravendb,代码行数:7,代码来源:SmugglerApi.cs

示例3: ExecuteInternal

		private void ExecuteInternal(RavenJToken token)
		{
			if (token == null)
				return; // nothing to do

			switch (token.Type)
			{
				case JTokenType.Array:
					foreach (var item in (RavenJArray)token)
					{
						ExecuteInternal(item);
					}
					break;
				case JTokenType.String:
					var value = token.Value<string>();
					if (LoadedIds.Add(value) == false)
						return;
					var includedDoc = Database.Get(value, TransactionInformation);
					if (includedDoc != null)
						Add(includedDoc.Etag,includedDoc.ToJson());
					break;
				default:
					// here we ignore everything else
					// if it ain't a string or array, it is invalid
					// as an id
					break;
			}
		}
开发者ID:kblooie,项目名称:ravendb,代码行数:28,代码来源:AddIncludesCommand.cs

示例4: WriteValue

		private static void WriteValue(RavenJToken token, StringWriter sw, int margin, int indent)
		{
			switch (token.Type)
			{
				case JTokenType.Array:
					WriteJsonArray((RavenJArray)token, sw, margin, indent);
					break;
				case JTokenType.Object:
					WriteJsonObject((RavenJObject)token, sw, margin, indent);
					break;
				case JTokenType.Null:
					sw.Write("null");
					break;
				case JTokenType.String:
					sw.Write('"');
					sw.Write(token.ToString()
								.NormalizeWhitespace()
								.ShortViewOfString(margin - 2)
						);
					sw.Write('"');
					break;
				default:
					sw.Write(token.ToString().ShortViewOfString(margin));
					break;
			}
		}
开发者ID:neiz,项目名称:ravendb,代码行数:26,代码来源:ShortViewOfJson.cs

示例5: MatchFilters

		public virtual bool MatchFilters(RavenJToken item)
		{
			foreach (var filter in Filters)
			{
			    bool anyRecords = false;
				bool matchedFilter = false;
				foreach (var tuple in item.SelectTokenWithRavenSyntaxReturningFlatStructure(filter.Path))
				{
					if (tuple == null || tuple.Item1 == null)
						continue;

				    anyRecords = true;

					var val = tuple.Item1.Type == JTokenType.String
								? tuple.Item1.Value<string>()
								: tuple.Item1.ToString(Formatting.None);
					matchedFilter |= filter.Values.Any(value => String.Equals(val, value, StringComparison.OrdinalIgnoreCase)) ==
									 filter.ShouldMatch;
				}

                if (filter.ShouldMatch == false && anyRecords == false) // RDBQA-7
                    return true;

				if (matchedFilter == false)
					return false;
			}
			return true;
		}
开发者ID:925coder,项目名称:ravendb,代码行数:28,代码来源:SmugglerOptions.cs

示例6: WriteValue

        private static void WriteValue(RavenJToken token, CountingWriter sw, int width, int numberOfLines)
		{
			switch (token.Type)
			{
				case JTokenType.Array:
                    WriteJsonArray((RavenJArray)token, sw, width, numberOfLines);
					break;
				case JTokenType.Object:
                    WriteJsonObject((RavenJObject)token, sw, width, numberOfLines);
					break;
				case JTokenType.Null:
					sw.Write("null");
					break;
				case JTokenType.String:
					sw.Write("\"");
					sw.Write(token.ToString()
								.NormalizeWhitespace()
                                .TrimmedViewOfString(width - sw.CharactersOnCurrentLine -1)
						);
                    sw.Write("\"");
					break;
				default:
                    sw.Write(token.ToString().TrimmedViewOfString(width - sw.CharactersOnCurrentLine - 1));
					break;
			}
		}
开发者ID:remcoros,项目名称:ravendb,代码行数:26,代码来源:ShortViewOfJson.cs

示例7: Visit

        private static void Visit(RavenJToken token)
        {
            switch (token.Type)
            {
                case JTokenType.Object:
                    foreach (var item in (RavenJObject)token)
                        Visit(item.Value);

                    break;

                case JTokenType.Array:
                    foreach (var items in (RavenJArray)token)
                        Visit(items);

                    break;

                case JTokenType.Constructor:
                case JTokenType.Property:
                case JTokenType.Comment:
                case JTokenType.None:
                case JTokenType.Integer:
                case JTokenType.Float:
                case JTokenType.String:
                case JTokenType.Boolean:
                case JTokenType.Null:
                case JTokenType.Undefined:
                case JTokenType.Date:
                case JTokenType.Raw:
                case JTokenType.Bytes:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(token.Type.ToString());
            }
        }
开发者ID:ravendb,项目名称:ravendb.contrib,代码行数:35,代码来源:JsonFormatter.cs

示例8: GetJsonTokenType

		private static JsonToken GetJsonTokenType(RavenJToken token)
		{
			switch (token.Type)
			{
				case JTokenType.Integer:
					return JsonToken.Integer;
				case JTokenType.Float:
					return JsonToken.Float;
				case JTokenType.String:
					return JsonToken.String;
				case JTokenType.Boolean:
					return JsonToken.Boolean;
				case JTokenType.Null:
					return JsonToken.Null;
				case JTokenType.Undefined:
					return JsonToken.Undefined;
				case JTokenType.Date:
					return JsonToken.Date;
				case JTokenType.Raw:
					return JsonToken.Raw;
				case JTokenType.Bytes:
					return JsonToken.Bytes;
				default:
					throw MiscellaneousUtils.CreateArgumentOutOfRangeException("Type", token.Type, "Unexpected JTokenType.");
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:26,代码来源:RavenJTokenReader.cs

示例9: ReadRavenJToken

		private static IEnumerable<ReadState> ReadRavenJToken(RavenJToken token)
		{
			if (token is RavenJValue)
			{
				yield return new ReadState(GetJsonTokenType(token), ((RavenJValue)token).Value);
			}
			else if (token is RavenJArray)
			{
				yield return new ReadState(JsonToken.StartArray);
				if (((RavenJArray)token).Length > 0) // to prevent object creation if inner array is null
				{
					foreach (var item in ((RavenJArray)token))
						foreach (var i in ReadRavenJToken(item))
							yield return i;
				}
				yield return new ReadState(JsonToken.EndArray);
			}
			else if (token is RavenJObject)
			{
				yield return new ReadState(JsonToken.StartObject);

				foreach (var prop in ((RavenJObject)token))
				{
					yield return new ReadState(JsonToken.PropertyName, prop.Key);
					foreach (var item in ReadRavenJToken(prop.Value))
						yield return item;
				}

				yield return new ReadState(JsonToken.EndObject);
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:31,代码来源:RavenJTokenReader.cs

示例10: ExecuteInternal

		private void ExecuteInternal(RavenJToken token, string prefix)
		{
			if (token == null)
				return; // nothing to do

			switch (token.Type)
			{
				case JTokenType.Array:
					foreach (var item in (RavenJArray)token)
					{
						ExecuteInternal(item, prefix);
					}
					break;
				case JTokenType.String:
					LoadId(token.Value<string>(), prefix);
					break;
				case JTokenType.Integer:
					LoadId(token.Value<int>().ToString(CultureInfo.InvariantCulture), prefix);
					break;
				default:
					// here we ignore everything else
					// if it ain't a string or array, it is invalid
					// as an id
					break;
			}
		}
开发者ID:seankearon,项目名称:ravendb,代码行数:26,代码来源:AddIncludesCommand.cs

示例11: RavenJTokenReader

		/// <summary>
		/// Initializes a new instance of the <see cref="RavenJTokenReader"/> class.
		/// </summary>
		/// <param name="token">The token to read from.</param>
		public RavenJTokenReader(RavenJToken token)
		{
			if (token == null)
				throw new ArgumentNullException("token");

			_root = token;
		}
开发者ID:royra,项目名称:ravendb,代码行数:11,代码来源:RavenJTokenReader.cs

示例12: ExecuteInternal

		private static void ExecuteInternal(RavenJToken token, string prefix, Func<string, string, bool> loadId)
		{
			if (token == null)
				return; // nothing to do

			switch (token.Type)
			{
				case JTokenType.Array:
					foreach (var item in (RavenJArray)token)
					{
						ExecuteInternal(item, prefix, loadId);
					}
					break;
				case JTokenType.String:
			        var value = token.Value<string>();
                    if (loadId(value, null) == false)
                        loadId(value, prefix);
					break;
				case JTokenType.Integer:
					try
					{
						loadId(token.Value<long>().ToString(CultureInfo.InvariantCulture), prefix);
					}
					catch (OverflowException)
					{
						loadId(token.Value<ulong>().ToString(CultureInfo.InvariantCulture), prefix);
					}
					break;
				// here we ignore everything else
				// if it ain't a string or array, it is invalid
				// as an id
			}
		}
开发者ID:robashton,项目名称:ravendb,代码行数:33,代码来源:IncludesUtil.cs

示例13: HandleToken

			private IEnumerable<IEnumerable<AbstractField>> HandleToken(RavenJToken value, string path)
			{
				switch (value.Type)
				{
					case JTokenType.Array:
						foreach (var item in ((RavenJArray) value).SelectMany(val => HandleToken(val, path)))
						{
							yield return item;
						}
						break;
					case JTokenType.Object:
						foreach (var inner in ((RavenJObject)value))
						{
							var nestedObj = inner.Value as RavenJObject;
							if(nestedObj!=null)
							{
								foreach (var item in HandleObject(nestedObj, path + "_" + inner.Key))
								{
									yield return item;
								}
							}
							else
							{
								foreach (var item in HandleToken(inner.Value, path +"_" + inner.Key))
								{
									yield return item;
								}
							}
						}
						break;
					default:
						yield return CreateField(path, value);
						break;
				}
			}
开发者ID:royra,项目名称:ravendb,代码行数:35,代码来源:NestedIndexDynamic.cs

示例14: GetTheNewResultOrWireTheDefault

			private RavenJToken GetTheNewResultOrWireTheDefault(RavenJToken result)
			{
				var selectToken = result.SelectToken(Name);
				if (selectToken != null)
					return selectToken;
				return ((RavenJObject)result)[Name] = new RavenJObject();
			}
开发者ID:royra,项目名称:ravendb,代码行数:7,代码来源:JTokenExtensions.cs

示例15: Add

		// This is called only from inside persistenceStore.Write

		public void Add(RavenJToken key)
		{
			IComparable actualKey = transform(key);
			Index = Index.AddOrUpdate(actualKey,
				new EmptyAVLTree<RavenJToken, RavenJToken>(RavenJTokenComparer.Instance, token => token.CloneToken(), token => token.CloneToken()).Add(key, key),
				(comparable, tree) => tree.Add(key, key));
		}
开发者ID:jtmueller,项目名称:ravendb,代码行数:9,代码来源:SecondaryIndex.cs


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