private JsonObjectTypeDescription(JsonObjectType type, bool isAlwaysRequired, bool isDictionary = false, string format = null)
 {
     Type = type;
     IsAlwaysRequired = isAlwaysRequired;
     Format = format;
     IsDictionary = isDictionary;
 }
예제 #2
0
 protected JsonValue(JsonObjectType type) : base(type)
 {
     if (!((type & JsonObjectType.Value) == JsonObjectType.Value))
     {
         throw new ArgumentOutOfRangeException(nameof(type), type, "Must be of type value");
     }
 }
        public string Build(JsonObjectType jsonObjectType) {
            char startContainer, endContainer;
            _factory.Parse(jsonObjectType, out startContainer, out endContainer);

            int startContainerCount = 1, endContainerCount = 0;
            int current;
            var isPropertyValue = false;

            var stringBuilder = new StringBuilder();
            stringBuilder.Append(_jsonReader.ReadToValue(startContainer).ToArray());

            const char quote = (char) 34;
            do {
                current = _binaryReader.Read();
                var character = (char) current;

                if (character.Equals(quote) && !isPropertyValue)
                    isPropertyValue = true;
                else if (character.Equals(quote) && isPropertyValue)
                    isPropertyValue = false;
                else if (character.Equals(startContainer) && !isPropertyValue)
                    startContainerCount++;
                else if (character.Equals(endContainer) && !isPropertyValue)
                    endContainerCount++;

                stringBuilder.Append(character);
            } while (current > -1 && !endContainerCount.Equals(startContainerCount));

            return !endContainerCount.Equals(startContainerCount) ?
                string.Concat(startContainer, endContainer) : stringBuilder.ToString();
        }
예제 #4
0
 /// <summary>
 /// Creates a new JSON stack object
 /// </summary>
 internal JsonStackObject(string name, JsonObjectType type)
 {
     this.Name = name;
     this.Type = type;
 }
예제 #5
0
 protected JsonObject(JsonObjectType type)
 {
     Type = type;
 }