Пример #1
0
            public void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer)
            {
                var dict = (Dictionary <string, string>)nestedObjectDeserializer(typeof(Dictionary <string, string>));

                // There should only be one item.
                Debug.Assert(dict.Count == 1);
                var kind = dict.Keys.ElementAt(0);

                Value = dict[kind];

                switch (kind.ToLowerInvariant())
                {
                case "arxiv":
                    Kind = BibliographyKind.arXiv;
                    break;

                case "doi":
                    Kind = BibliographyKind.DOI;
                    break;

                default:
                    Kind = BibliographyKind.URL;
                    break;
                }
            }
            public void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer)
            {
                var dict = (Dictionary <string, string>)nestedObjectDeserializer(typeof(Dictionary <string, string>));

                // There should only be one item.
                Debug.Assert(dict.Count == 1);
                var kind = dict.Keys.ElementAt(0);

                Value = dict[kind];

                Kind = kind.ToLowerInvariant() switch
                {
                    "arxiv" => BibliographyKind.arXiv,
                    "doi" => BibliographyKind.DOI,
                    _ => BibliographyKind.URL
                };
            }