Wiki
Clone wikiOpenBadges.Model / Home
OpenBadges Model C# Library
Welcome to the home for OpenBadges Model C# Library. This library is intended to help dealing with serialization/deserialization of OpenBadges specifications in a C# environment.
You can find all the related information about Mozilla OpenBadges and its implementation at http://openbadges.org and https://wiki.mozilla.org/Badges.
Installation
Just use Nuget (https://www.nuget.org/packages/OpenBadges.Model/):
- Search for "OpenBadges.Model" with the Library Package Manager in VS.
-
Or type in the Package Manager Console
Install-Package OpenBadges.Model
This will install the reference to the library in your project.
Features supported
The library represents the whole model specified at Badge Assertion Specs.
Playing with it
Here is a small example that makes some calls using the model. Put it on a small Console project:
#!c# using OpenBadges.Model.Assertion; private static void Main(string[] args) { // Badge Assertion sample JSON string String json = @"{ ""uid"": ""f2c20"", ""recipient"": { ""type"": ""email"", ""hashed"": true, ""salt"": ""deadsea"", ""identity"": ""sha256$c7ef86405ba71b85acd8e2e95166c4b111448089f2e1599f42fe1bba46e865c5"" }, ""image"": ""https://example.org/beths-robot-badge.png"", ""evidence"": ""https://example.org/beths-robot-work.html"", ""issuedOn"": 1359217910, ""badge"": ""https://example.org/robotics-badge.json"", ""verify"": { ""type"": ""hosted"", ""url"": ""https://example.org/beths-robotics-badge.json"" } }"; // Build a BadgeAssertion from a JSON string // via constructor: IBadgeAssertion badgeAssertion = new BadgeAssertion(json); // via static load method: IBadgeAssertion badge = BadgeAssertion.Load(json); // Convert the BadgeAssertion object to JSON (plain & indented) Console.WriteLine(badgeAssertion.ToJson()); Console.WriteLine(badgeAssertion.ToJson(indented: true)); // ToString method is overrided to get the JSON string representing the badge, as well Console.WriteLine(badgeAssertion); }
Disclaimer
This is a first alpha release, so it's not as stable as it could be, but enough to play around with it. The source code will be open sourced soon so that you could contribute and improve it if you wish ;) Use it at your own risk.
I am not related with OpenBadges in any way. This is not an official OpenBadges library. It's just a small piece of my work :)
The license applied for using this software is the MIT License.
Updated