Class OpenGraph
Represents Open Graph meta data parsed from HTML.
Inheritance
Namespace: OpenGraphNet
Assembly: OpenGraphNet.dll
Syntax
public class OpenGraph : Object
Properties
HeadPrefixAttributeValue
Gets the head prefix attribute value.
Declaration
public string HeadPrefixAttributeValue { get; }
Property Value
Type | Description |
---|---|
System.String | The head prefix attribute value. |
HtmlXmlnsValues
Gets the HTML XML namespace values.
Declaration
public string HtmlXmlnsValues { get; }
Property Value
Type | Description |
---|---|
System.String | The HTML XML namespace values. |
Image
Gets the image for the open graph document.
Declaration
public Uri Image { get; }
Property Value
Type | Description |
---|---|
System.Uri | The image. |
Metadata
Gets the data.
Declaration
public IDictionary<string, IList<StructuredMetadata>> Metadata { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, System.Collections.Generic.IList<StructuredMetadata>> | The data. |
Namespaces
Gets the namespaces.
Declaration
public IDictionary<string, OpenGraphNamespace> Namespaces { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IDictionary<System.String, OpenGraphNamespace> | The namespaces. |
OriginalHtml
Gets the original HTML content.
Declaration
public string OriginalHtml { get; }
Property Value
Type | Description |
---|---|
System.String | The original HTML content. |
OriginalUrl
Gets the original URL used to generate this graph.
Declaration
public Uri OriginalUrl { get; }
Property Value
Type | Description |
---|---|
System.Uri | The original URL. |
Title
Gets the title of the open graph document.
Declaration
public string Title { get; }
Property Value
Type | Description |
---|---|
System.String | The title. |
Type
Gets the type.
Declaration
public string Type { get; }
Property Value
Type | Description |
---|---|
System.String | The type of open graph document. |
Url
Gets the URL for the open graph document.
Declaration
public Uri Url { get; }
Property Value
Type | Description |
---|---|
System.Uri | The URL. |
Methods
AddMetadata(StructuredMetadata)
Adds the meta element.
Declaration
public void AddMetadata(StructuredMetadata element)
Parameters
Type | Name | Description |
---|---|---|
StructuredMetadata | element | The element. |
AddMetadata(String, String, String)
Adds the metadata.
Declaration
public void AddMetadata(string prefix, string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The prefix. |
System.String | name | The name. |
System.String | value | The value. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | The prefix {prefix} does not exist in the NamespaceRegistry. |
MakeGraph(String, String, String, String, String, String, String, String, String, IList<String>, String)
Makes the graph.
Declaration
public static OpenGraph MakeGraph(string title, string type, string image, string url, string description = "", string siteName = "", string audio = "", string video = "", string locale = "", IList<string> localeAlternates = null, string determiner = "")
Parameters
Type | Name | Description |
---|---|---|
System.String | title | The title. |
System.String | type | The type. |
System.String | image | The image. |
System.String | url | The URL. |
System.String | description | The description. |
System.String | siteName | Name of the site. |
System.String | audio | The audio. |
System.String | video | The video. |
System.String | locale | The locale. |
System.Collections.Generic.IList<System.String> | localeAlternates | The locale alternates. |
System.String | determiner | The determiner. |
Returns
Type | Description |
---|---|
OpenGraph |
ParseHtml(String, Boolean)
Parses the HTML for open graph content.
Declaration
public static OpenGraph ParseHtml(string content, bool validateSpecification = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | content | The HTML to parse. |
System.Boolean | validateSpecification | if set to |
Returns
Type | Description |
---|---|
OpenGraph |
ParseUrlAsync(String, String, Boolean, Int32, CancellationToken)
Parses the URL asynchronously.
Declaration
public static Task<OpenGraph> ParseUrlAsync(string url, string userAgent = null, bool validateSpecification = false, int timeout = 90000, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | url | The URL. |
System.String | userAgent | The user agent. |
System.Boolean | validateSpecification | if set to |
System.Int32 | timeout | The timeout in milliseconds. |
System.Threading.CancellationToken | cancellationToken | The cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<OpenGraph> | System.Threading.Tasks.Task<>. |
ParseUrlAsync(Uri, String, Boolean, Int32, CancellationToken)
Parses the URL asynchronously.
Declaration
public static Task<OpenGraph> ParseUrlAsync(Uri url, string userAgent = "", bool validateSpecification = false, int timeout = 90000, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | url | The URL. |
System.String | userAgent | The user agent. |
System.Boolean | validateSpecification | if set to |
System.Int32 | timeout | The timeout in milliseconds. |
System.Threading.CancellationToken | cancellationToken | The cancellation token that can be used by other objects or threads to receive notice of cancellation. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<OpenGraph> | System.Threading.Tasks.Task<>. |
ToString()
Returns a System.String that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |