Discard() public method

Read and discard the next content value. If the next content type is JsonNodeType.OpenObject or JsonNodeType.OpenArray, then the reader will continue to read and discard content until the matching JsonNodeType.CloseObject or JsonNodeType.CloseArray content type is found. For all other content types, no additional reads are made.
public Discard ( string path ) : void
path string
return void
        private object Read(JsonReader reader, IJsonSerializeOperationInfo info)
        {
            var factory = _createObjectFactory.Value.Invoke();

            foreach (var propertyName in reader.ReadProperties())
            {
                if (!factory.SetValue(reader, propertyName, info))
                {
                    reader.Discard();
                }
            }

            return(factory.GetInstance());
        }
Example #2
0
        private object Read(JsonReader reader, IJsonSerializeOperationInfo info, string path)
        {
            var factory = _createObjectFactory.Value.Invoke();

            foreach (var propertyName in reader.ReadProperties(path))
            {
                var propertyPath = path.AppendProperty(propertyName);

                if (!factory.SetValue(reader, propertyName, info, propertyPath))
                {
                    reader.Discard(propertyPath);
                }
            }

            return(factory.GetInstance());
        }
        private object Read(JsonReader reader, IJsonSerializeOperationInfo info, string path)
        {
            var factory = _createObjectFactory.Value.Invoke();

            foreach (var propertyName in reader.ReadProperties(path))
            {
                var propertyPath = path.AppendProperty(propertyName);

                if (!factory.SetValue(reader, propertyName, info, propertyPath))
                {
                    reader.Discard(propertyPath);
                }
            }

            return factory.GetInstance();
        }
        private object Read(JsonReader reader, IJsonSerializeOperationInfo info)
        {
            var factory = _createObjectFactory.Value.Invoke();

            foreach (var propertyName in reader.ReadProperties())
            {
                if (!factory.SetValue(reader, propertyName, info))
                {
                    reader.Discard();
                }
            }

            return factory.GetInstance();
        }