Dragonfly.Net5 1.6.0

dotnet add package Dragonfly.Net5 --version 1.6.0
NuGet\Install-Package Dragonfly.Net5 -Version 1.6.0
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="Dragonfly.Net5" Version="1.6.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dragonfly.Net5 --version 1.6.0
#r "nuget: Dragonfly.Net5, 1.6.0"
#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.
// Install Dragonfly.Net5 as a Cake Addin
#addin nuget:?package=Dragonfly.Net5&version=1.6.0

// Install Dragonfly.Net5 as a Cake Tool
#tool nuget:?package=Dragonfly.Net5&version=1.6.0

Dragonfly.Net5

A collection of .Net Helpers/Models created by Heather Floyd.

Installation

Nuget Downloads

PM > Install-Package Dragonfly.Net5

Features & Usage : Models

StatusMessage

An object used for collecting and reporting information about code operations - a great way to return more detailed information from your custom functions and APIs. You can assign any Exceptions, as well as nest statuses. Explore all the properties and methods for details.

Example Usage:

public StatusMessage GetLocalFilesInfo(out List<FileInfo> FilesList)
{
    FilesList = new List<FileInfo>();
    var returnStatus = new StatusMessage(true);
    returnStatus.ObjectName = "GetLocalFilesInfo";

    IEnumerable<FileInfo> files;
    var statusGetListOfFiles = GetListOfFiles(out files);
    returnStatus.InnerStatuses.Add(statusGetListOfFiles);

    if (files.Any())
    {
        foreach (var fileInfo in files)
        {
            StatusMessage readStatus = new StatusMessage(true);
            readStatus.RunningFunctionName = "GetLocalFilesInfo";
            try
            {
                FilesList.Add(fileInfo);
            }
            catch (Exception e)
            {
                readStatus.Success = false;
                readStatus.Message = $"GetLocalFilesInfo: Failure getting file '{fileInfo.FullName}'.";
                readStatus.SetRelatedException(e);
            }
            returnStatus.InnerStatuses.Add(readStatus);
        }
    }

    return returnStatus;
}

HttpResponseMessageResult

Allows you to use familiar HttpResponse syntax from .Net Framework to return an IActionResult.

Example

    [HttpGet]
    public IActionResult DoSomethings()
    {
        var status = new StatusMessage(true);

        try
        {
			//These two service calls resturn Status messages themselves, so we have additional data
            status.InnerStatuses.Add(_MyService.DoSomething);
            status.InnerStatuses.Add(_MyService.DoSomethingElse);
        }
        catch (Exception ex)
        {
            status.RelatedException = ex;
            status.Success = false;
            status.Message = $"Failure while running Code: FetchAllRemoteNodesData('{EnvironmentType}',{UpdateRemoteFirst})";
            _logger.LogError(ex, status.Message);
        }

        //Return JSON
        string json = JsonConvert.SerializeObject(status);
        var result = new HttpResponseMessage()
        {
            Content = new StringContent(
                json,
                Encoding.UTF8,
                "application/json"
            )
        };

        return new HttpResponseMessageResult(result);
    }

Features & Usage : Static Helpers

TBA

Features & Usage : Helper Services

ViewRenderService

Renders an MVC View to a HTML string.

Example: Dependency Injection - Setup.cs

...
services.AddScoped<IViewRenderService, ViewRenderService>();
...

(Might also need:)
services.AddMvcCore().AddRazorViewEngine();
services.AddControllersWithViews();
services.AddRazorPages();

Example: Usage (in a Controller)

public class MyController : Controller
{
    private readonly IViewRenderService _viewRenderService;

	public MyController(IViewRenderService viewRenderService)
    {
        _viewRenderService = viewRenderService;
    }

    [HttpGet]
    public IActionResult DoStuff()
    {
		//VIEW PATH
		var viewPath = "~/SomeFolder/Views/MyView.cshtml"; 
		//(Or, if in standard View folders, "MyView" will be sufficient.)
	
		//GET DATA TO DISPLAY
	    SomeModel model = new SomeModel(); //Do stuff to actually have data here...
	   
	    //VIEW DATA (OPTIONAL)
	    var viewData = new Dictionary<string, object>();
	    viewData.Add("Title", "The title for the view");
	    viewData.Add("Qty", 5);
	
	    //RENDER
	    var htmlTask = _viewRenderService.RenderToStringAsync(this.HttpContext, viewPath, model, viewData);
	    var displayHtml = htmlTask.Result;
		...
	}

Example: Usage (in a Controller) - ASYNC

... 
 string html = await _viewRenderService.RenderToStringAsync("MyViewFile", new Model());
...
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on Dragonfly.Net5:

Package Downloads
Dragonfly.Umbraco9

A collection of Umbraco 9+ Helpers & Models (min. Umbraco 9.3.0)

Dragonfly.Umbraco9.SchemaImporter

A tool to quickly import a generated package.xml file into the back-office of an Umbraco 9 Site

Dragonfly.Umbraco9DeployTools

Tools to compare Content and Media across Umbraco Deploy environments (min. Umbraco 9.3.0)

Dragonfly.Umbraco10.SiteTester

Tools to test pages in an Umbraco 10 website

Dragonfly.Umbraco9SiteAuditor

A collection of tools to extract data about an Umbraco 9 or 10 site. (min. Umbraco 9.3.0)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.6.0 350 7/3/2023
1.5.0 874 2/9/2023
1.4.0 459 1/28/2023
1.3.0 1,198 10/5/2022
1.2.0 998 8/11/2022
1.1.0 1,365 3/31/2022

Updates including: Adding .Url() extension to HttpRequest