Esempio n. 1
0
        private void ReadCardPropertyValue(ref Utf8JsonReader reader, ContactCardProperty cardProperty)
        {
            cardProperty.Type = reader.GetString();

            reader.Read();

            bool array = false;

            if (reader.TokenType == JsonTokenType.StartArray)
            {
                array = true;

                reader.Read();
            }

            while (reader.TokenType == JsonTokenType.String)
            {
                cardProperty.Value.Add(reader.GetString());

                reader.Read();
            }

            if (array)
            {
                reader.Read();
            }
        }
Esempio n. 2
0
        private void ReadCardPropertyParameters(ref Utf8JsonReader reader, ContactCardProperty cardProperty)
        {
            if (reader.TokenType != JsonTokenType.StartObject)
            {
                throw new JsonException($"Expected StartObject; Actual: {reader.TokenType}");
            }

            while (reader.Read() && reader.TokenType != JsonTokenType.EndObject)
            {
                var key = reader.GetString();
                reader.Read();

                object value;

                if (reader.TokenType == JsonTokenType.StartArray)
                {
                    var array = new List <string>();

                    while (reader.Read() && reader.TokenType != JsonTokenType.EndArray)
                    {
                        array.Add(reader.GetString());
                    }

                    value = array;
                }
                else
                {
                    value = reader.GetString();
                }

                cardProperty.Parameters[key] = value;
            }

            reader.Read();
        }
Esempio n. 3
0
        private void ReadCardProperty(ref Utf8JsonReader reader, ContactCard card)
        {
            if (reader.TokenType != JsonTokenType.StartArray)
            {
                throw new JsonException($"Expected StartArray; Actual: {reader.TokenType}");
            }

            reader.Read();

            var cardProperty = new ContactCardProperty()
            {
                Name = reader.GetString()
            };

            reader.Read();

            card[cardProperty.Name] = cardProperty;

            ReadCardPropertyParameters(ref reader, cardProperty);

            ReadCardPropertyValue(ref reader, cardProperty);
        }