Beispiel #1
0
 public static IGraphQLRequest PageModelData(ContentNamespace ns, int publicationId, int pageId,
                                             PageInclusion pageInclusion, ContentIncludeMode contentIncludeMode, IContextData contextData,
                                             IContextData globalContextData) =>
 new QueryBuilder().WithQueryResource("PageModelById", true)
 .WithNamespace(ns)
 .WithPublicationId(publicationId)
 .WithPageId(pageId)
 .WithContentIncludeMode(contentIncludeMode)
 .WithContextClaim(CreateClaim(pageInclusion))
 .WithContextData(contextData)
 .WithContextData(globalContextData)
 .Build();
 public dynamic GetPageModelData(ContentNamespace ns, int publicationId, string url,
                                 PageInclusion pageInclusion, ContentIncludeMode contentIncludeMode, IContextData contextData)
 {
     try
     {
         var response =
             _client.Execute(GraphQLRequests.PageModelData(ns, publicationId, url,
                                                           pageInclusion, contentIncludeMode, contextData, GlobalContextDataInternal));
         return(response.Data.page.rawContent.data);
     }
     catch (RuntimeBinderException e)
     {
         throw new ApiException(
                   $"Failed to get page model data (namespaceId:{ns}, publicationId:{publicationId}, url:{url}", e);
     }
 }
        public async Task <dynamic> GetPageModelDataAsync(ContentNamespace ns, int publicationId, string url,
                                                          PageInclusion pageInclusion, ContentIncludeMode contentIncludeMode, IContextData contextData,
                                                          CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var response =
                    await
                    _client.ExecuteAsync(
                        GraphQLRequests.PageModelData(ns, publicationId, url, pageInclusion,
                                                      contentIncludeMode, contextData, GlobalContextDataInternal), cancellationToken)
                    .ConfigureAwait(false);

                return(response.Data.page.rawContent.data);
            }
            catch (RuntimeBinderException e)
            {
                throw new ApiException(
                          $"Failed to get page model data (namespaceId:{ns}, publicationId:{publicationId}, url:{url}", e);
            }
        }
Beispiel #4
0
 public static ClaimValue CreateClaim(PageInclusion pageInclusion) => new ClaimValue
 {
     Uri   = ClaimUris.PageIncludeRegions,
     Type  = ClaimValueType.STRING,
     Value = Enum.GetName(typeof(PageInclusion), pageInclusion)
 };