Osirion.Blazor.Cms.Infrastructure 2.1.3

dotnet add package Osirion.Blazor.Cms.Infrastructure --version 2.1.3
                    
NuGet\Install-Package Osirion.Blazor.Cms.Infrastructure -Version 2.1.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Osirion.Blazor.Cms.Infrastructure" Version="2.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Osirion.Blazor.Cms.Infrastructure" Version="2.1.3" />
                    
Directory.Packages.props
<PackageReference Include="Osirion.Blazor.Cms.Infrastructure" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Osirion.Blazor.Cms.Infrastructure --version 2.1.3
                    
#r "nuget: Osirion.Blazor.Cms.Infrastructure, 2.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Osirion.Blazor.Cms.Infrastructure&version=2.1.3
                    
Install Osirion.Blazor.Cms.Infrastructure as a Cake Addin
#tool nuget:?package=Osirion.Blazor.Cms.Infrastructure&version=2.1.3
                    
Install Osirion.Blazor.Cms.Infrastructure as a Cake Tool

Osirion.Blazor.Cms.Infrastructure

NuGet License

Infrastructure layer for the Osirion.Blazor CMS ecosystem, implementing repositories, external service integrations, and infrastructure concerns.

Overview

The Infrastructure project implements the Infrastructure layer in the Clean Architecture pattern, providing concrete implementations of the interfaces defined in the Domain and Application layers. It includes repositories, API clients, storage implementations, and external service integrations.

Features

  • GitHub Provider: Content repository implementation using GitHub API
  • File System Provider: Local file system content repository
  • Caching Integration: Memory and distributed cache implementations
  • HTTP Clients: Typed HTTP clients for external service communication
  • Local Storage: Browser local storage adapter for client-side persistence
  • Dependency Injection: Infrastructure service registration extensions

GitHub Provider

Content provider implementation using the GitHub API via Octokit.NET:

public class GitHubContentRepository : IContentRepository
{
    private readonly GitHubClient _client;
    private readonly IMemoryCache _cache;
    private readonly ILogger<GitHubContentRepository> _logger;
    private readonly GitHubContentOptions _options;

    public GitHubContentRepository(
        IHttpClientFactory httpClientFactory,
        IMemoryCache cache,
        IOptions<GitHubContentOptions> options,
        ILogger<GitHubContentRepository> logger)
    {
        _cache = cache;
        _logger = logger;
        _options = options.Value;
        
        _client = new GitHubClient(new ProductHeaderValue("Osirion.Blazor.Cms"));
        
        if (!string.IsNullOrEmpty(_options.PersonalAccessToken))
        {
            _client.Credentials = new Credentials(_options.PersonalAccessToken);
        }
    }

    public async Task<ContentItem?> GetByPathAsync(string path)
    {
        try
        {
            var cacheKey = $"github:content:{path}";
            
            if (_cache.TryGetValue(cacheKey, out ContentItem? cachedItem))
            {
                return cachedItem;
            }
            
            var contentResponse = await _client.Repository.Content.GetAllContents(
                _options.Owner, 
                _options.Repository,
                Path.Combine(_options.ContentPath, path));
                
            var content = contentResponse.FirstOrDefault();
            
            if (content == null)
            {
                return null;
            }
            
            var decodedContent = content.Encoding == ContentEncoding.Base64
                ? Encoding.UTF8.GetString(Convert.FromBase64String(content.Content))
                : content.Content;
                
            var contentItem = await ProcessContentAsync(path, decodedContent);
            
            var cacheOptions = new MemoryCacheEntryOptions()
                .SetSlidingExpiration(TimeSpan.FromMinutes(_options.CacheExpirationMinutes));
                
            _cache.Set(cacheKey, contentItem, cacheOptions);
            
            return contentItem;
        }
        catch (NotFoundException)
        {
            _logger.LogWarning("Content not found in GitHub repository: {Path}", path);
            return null;
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Error fetching content from GitHub: {Path}", path);
            throw;
        }
    }
    
    // Additional repository methods
}

Configuration Options

Configuration options for the infrastructure providers:

public class GitHubContentOptions
{
    public string Owner { get; set; } = string.Empty;
    public string Repository { get; set; } = string.Empty;
    public string Branch { get; set; } = "main";
    public string ContentPath { get; set; } = "content";
    public string? PersonalAccessToken { get; set; }
    public bool UseCache { get; set; } = true;
    public int CacheExpirationMinutes { get; set; } = 60;
}

public class FileSystemContentOptions
{
    public string BasePath { get; set; } = "content";
    public bool WatchForChanges { get; set; } = false;
    public bool UseCache { get; set; } = true;
    public int CacheExpirationMinutes { get; set; } = 60;
}

Dependencies

The infrastructure layer has the following dependencies:

  • Osirion.Blazor.Cms.Domain: For domain entities and interfaces
  • Osirion.Blazor.Cms.Application: For application services and interfaces
  • Octokit: For GitHub API integration
  • Blazored.LocalStorage: For browser local storage access
  • Microsoft.Extensions.Caching.Memory: For memory caching
  • Microsoft.Extensions.Http: For HTTP client factory

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Osirion.Blazor.Cms.Infrastructure:

Package Downloads
Osirion.Blazor.Cms.Core

Core CMS module for Osirion.Blazor - Provides cms management with provider pattern.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.3 87 5/31/2025
2.1.2 57 5/31/2025
2.1.0 214 5/20/2025