Skip to content

Instantly share code, notes, and snippets.

@brianweet
Last active February 13, 2020 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brianweet/4eb4a0499830682d7db45247fbf6d244 to your computer and use it in GitHub Desktop.
Save brianweet/4eb4a0499830682d7db45247fbf6d244 to your computer and use it in GitHub Desktop.
BynderAssetMetaDataMapper.cs
using System;
using System.Collections.Generic;
using Bynder.ContentTypes;
using Newtonsoft.Json.Linq;
namespace Bynder
{
// This is the default metadata mapper, you can use it as a base class or replace it
public class BynderAssetMetaDataMapper : IBynderAssetMetaDataMapper
{
public virtual BynderAssetData MapMetaData(BynderAssetData bynderAsset, Dictionary<string, JToken> dictionary)
{
if (dictionary == null || dictionary.Count == 0)
{
return bynderAsset;
}
bynderAsset.UserCreated = dictionary.GetValue<string>("userCreated");
bynderAsset.MarkedAsArchived = dictionary.GetValue<bool>("archive");
bynderAsset.ShowWatermark = dictionary.GetValue<bool>("watermarked");
bynderAsset.LimitedUsage = dictionary.GetValue<bool>("limited");
bynderAsset.Views = dictionary.GetValue<int>("views");
bynderAsset.Downloads = dictionary.GetValue<int>("downloads");
bynderAsset.DatePublished = dictionary.GetValue<DateTime>("datePublished");
// Here you would map the new 'SEO name' field, which you can then use in the view to render the asset
return bynderAsset;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment