Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace cfclt
- {
- using System;
- using System.Collections.Generic;
- using System.Net.Http;
- using Contentful.Core;
- using Contentful.Core.Configuration;
- using Contentful.Core.Models;
- class Program
- {
- public class FieldTypesEntry
- {
- public double? NumberField { get; set; }
- public string StringField { get; set; }
- public Document RichTextField { get; set; }
- public List<Asset> AssetField { get; set; }
- public DateTime DateTimeField { get; set; }
- public void Render()
- {
- Console.WriteLine(GetType());
- Console.WriteLine("NumberField: " + NumberField);
- Console.WriteLine("StringField: " + StringField);
- Console.WriteLine("DateTimeField: " + DateTimeField);
- Console.WriteLine("RichTextField: " +
- new HtmlRenderer().ToHtml(RichTextField).GetAwaiter().GetResult());
- foreach (Asset assetField in AssetField)
- {
- Console.WriteLine("AssetField: " + assetField.File.Url);
- }
- }
- }
- static void Main(string[] args)
- {
- HttpClient httpClient = new HttpClient();
- ContentfulOptions options = new ContentfulOptions
- {
- DeliveryApiKey = "Gg3vpa21vheFi28wzcPT7LDy3CgOEb0VJ62cGiPi0JQ",
- PreviewApiKey = "aVrO8Fhmoq-hNEDa78_QHkeqKIxgG6-JhofdnNpCj00",
- SpaceId = "qjiunow8a0ig"
- };
- ContentfulClient client = new ContentfulClient(httpClient, options);
- client.GetEntry<FieldTypesEntry>("7gRkxpacpEf7yLjL1ukb4G").GetAwaiter().GetResult().Render();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement