public WebLink CreateWebLink(ReadOnlySpan <char> href, ReadOnlySpan <char> name = default, bool isTemplated = default, ReadOnlySpan <char> title = default, ReadOnlySpan <char> profile = default, ReadOnlySpan <char> type = default, ReadOnlySpan <char> hreflang = default) { using var stream = new MemoryStream(); var writer = new Utf8JsonWriter(stream); WebLinkWriter.WriteWebLink(writer, href, name, isTemplated, title, profile, type, hreflang); stream.Flush(); stream.Position = 0; return(new WebLink(JsonDocument.Parse(stream).RootElement.Clone())); }
public WebLink CreateWebLink(ReadOnlySpan <byte> utf8Href, ReadOnlySpan <byte> utf8Name = default, bool isTemplated = default, ReadOnlySpan <byte> utf8Title = default, ReadOnlySpan <byte> utf8Profile = default, ReadOnlySpan <byte> utf8Type = default, ReadOnlySpan <byte> utf8Hreflang = default) { using var stream = new MemoryStream(); var writer = new Utf8JsonWriter(stream); WebLinkWriter.WriteWebLink(writer, utf8Href, utf8Name, isTemplated, utf8Title, utf8Profile, utf8Type, utf8Hreflang); stream.Flush(); stream.Position = 0; return(new WebLink(JsonDocument.Parse(stream).RootElement.Clone())); }
public WebLink CreateWebLink(string href, string?name = null, bool?isTemplated = null, string?title = null, string?profile = null, string?type = null, string?hreflang = null) { if (href is null) { throw new ArgumentNullException(nameof(href)); } using var stream = new MemoryStream(); var writer = new Utf8JsonWriter(stream); WebLinkWriter.WriteWebLink(writer, href, name, isTemplated, title, profile, type, hreflang); stream.Flush(); stream.Position = 0; return(new WebLink(JsonDocument.Parse(stream).RootElement.Clone())); }