Пример #1
0
        private static void WriteJsonArray(RavenJArray array, CountingWriter sw, int width, int numberOfLines)
        {
            sw.WriteLine("[");
            sw.PushIndent();

            var isFirstItem = true;

            foreach (var token in array.Values())
            {
                if (sw.LinesWritten >= numberOfLines)
                {
                    break;
                }

                if (isFirstItem)
                {
                    isFirstItem = false;
                }
                else
                {
                    sw.WriteLine(",");
                }
                WriteValue(token, sw, width, numberOfLines);
            }
            sw.WriteLine("");
            sw.PopIndent();
            sw.Write("]");
        }
Пример #2
0
        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;
			}
		}
Пример #3
0
        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;
            }
        }
Пример #4
0
            public int calcStoryboardCommandSize()
            {
                Writer cw = new CountingWriter();

                new Sprite(this).fin(cw);
                return(cw.byteswritten);
            }
Пример #5
0
        public static string GetContentTrimmedToDimensions(RavenJObject dataAsJson, int widthInCharacters, int heightInLines)
        {
            var sw = new CountingWriter(2);

            WriteJsonObject(dataAsJson, sw, widthInCharacters, heightInLines);

            return(sw.ToString());
        }
Пример #6
0
		private static void WriteJsonObject(RavenJObject ravenJObject, CountingWriter sw, int width, int numberOfLines)
		{
			sw.WriteLine("{");
			sw.PushIndent();

			foreach (var item in ravenJObject)
			{
                if (sw.LinesWritten > numberOfLines)
                    break;

				sw.Write(item.Key);
				sw.Write(": ");
                WriteValue(item.Value, sw, width, numberOfLines);
				sw.WriteLine("");
			}

			sw.PopIndent();
			sw.Write("}");
		}
Пример #7
0
        private static void WriteJsonArray(RavenJArray array, CountingWriter sw, int width, int numberOfLines)
		{
			sw.WriteLine("[");
			sw.PushIndent();

			var isFirstItem = true;
			foreach (var token in array.Values())
			{
                if (sw.LinesWritten >= numberOfLines)
                    break;

				if (isFirstItem)
					isFirstItem = false;
				else
					sw.WriteLine(",");
                WriteValue(token, sw, width, numberOfLines);
			}
			sw.WriteLine("");
			sw.PopIndent();
			sw.Write("]");
		}
Пример #8
0
        private static void WriteJsonObject(RavenJObject ravenJObject, CountingWriter sw, int width, int numberOfLines)
        {
            sw.WriteLine("{");
            sw.PushIndent();

            foreach (var item in ravenJObject)
            {
                if (sw.LinesWritten > numberOfLines)
                {
                    break;
                }

                sw.Write(item.Key);
                sw.Write(": ");
                WriteValue(item.Value, sw, width, numberOfLines);
                sw.WriteLine("");
            }

            sw.PopIndent();
            sw.Write("}");
        }
Пример #9
0
	    public static string GetContentTrimmedToDimensions(RavenJObject dataAsJson, int widthInCharacters, int heightInLines)
	    {
	        var sw = new CountingWriter(2);

            WriteJsonObject(dataAsJson, sw, widthInCharacters, heightInLines);

	        return sw.ToString();
	    }