Open Graph Protocol Reader for .NET
Use NuGet package Shipwreck.OpenGraph.
using Shipwreck.OpenGraph;
Graph graph = Graph.FromXml(xml);
Graph.FromXmlReader(xmlReader);
Graph.FromXmlDocument(xmlDocument);
Graph.FromXPathNavigator(xDocument.CreateNavigator());
Graph.FromXPathNavigable(htmlDocument);
TextReader or Stream must be well-formed.
Graph.FromTextReader(textReader);
Graph.FromStream(stream);
The Graph
and its descendants inherits GraphObject
class. You can access GraphObject
's properties via GraphObject.LocalProperties
and GraphObject.Children
.
All properties in GraphObject
are mapped by PropertyPath
type which contains namespace URI and path.
Values of PropertyEntry.Property
in LocalProperties
are mostly relative. So it should be combined with GraphObject.Path
.
var entry = obj.LocalProperties[i];
var absolutePath = entry.Property.IsRelative ? ob.Path + entry.Property.Path : entry.Property;
Or you can use GraphObject.GetLocalProperties()
to enumerate properties with absolute path.
The Graph
has TypeObject
property that stores og:type
depended properties. As its properties are separated from Graph
, Graph.LocalProperties
and Children
does not include TypeObject
items.
You can access properties via various CLR properties.
(TBD)
All array properties contains both singular and collection properties. When multiple raw values exist, getting the singular will returns the first value. And setting it will clear existing entries.
Graph
has several properties that can access TypeObject
as derived types.
(TBD)
Graph.GetPrefixAttribute()
Graph.WriteTo