Blackhole.Core 1.0.5

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

// Install Blackhole.Core as a Cake Tool
#tool nuget:?package=Blackhole.Core&version=1.0.5                

Blackhole.Core

Blackhole.Core is a fun and creative .NET library that provides space-themed methods for various data operations. It offers a collection of utility methods that make data manipulation, transformation, and processing more entertaining while remaining practical. The library is designed to be used with dependency injection, promoting decoupled and testable code.

Features

  • 🕳️ Blackhole<T> - A method that discards any input, perfect for when you need to explicitly ignore or dispose of data.
  • 🌌 EventHorizon<T> - Conditionally discards data based on a predicate, returning default(T) if the condition is met.
  • 💫 Singularity - Compresses string data using GZip compression.
  • TimeDilation<T> - Introduces controlled delays in async operations, useful for testing or simulating network latency.
  • 🌀 Wormhole<T> - Transforms data through a custom transformation function.
  • 🚀 WarpDrive - Executes actions in parallel for improved performance.
  • ⚛️ QuantumEntanglement<T> - Synchronizes the state between two objects of the same type.
  • TimeTravel<T> - Reverts data to a previous state, simulating an undo operation.
  • 🍝 Spaghettify - Splits a string into individual characters.
  • 🔮 GravitationalLens - Creates a palindrome by appending the reverse of a string to itself.
  • 🌪️ KerrMetric - Rotates a string by a specified number of characters.
  • 🌌 CosmicExpansion - Inserts a separator between each character in a string.
  • 🔬 PlanckProcessor - Applies a character-level transformation to a string.
  • ☢️ HawkingRadiation - Simulates data evaporation over time, useful for progressive displays or countdowns.
  • 🚀 Hyperspace - Encodes a string into Base64, simulating a hyperspace jump.
  • 🛠️ InformationParadox<T> - Recovers or transforms data, resolving the Information Paradox.
  • 🌑 SingularityCollapse<T> - Collapses data into a singularity and transforms it.
  • QuantumAccelerator - Performs element-wise arithmetic operations on an array of floats using SIMD vectorization.

Installation

Install the package via NuGet Package Manager:

Install-Package Blackhole.Core

Or via .NET CLI:

dotnet add package Blackhole.Core

Usage

To use Blackhole.Core, you should set up dependency injection to inject the IBlackholeCore interface into your classes.

Setting Up Dependency Injection

using Blackhole.Core;
using Microsoft.Extensions.DependencyInjection;

var services = new ServiceCollection();

// Register IBlackholeCore with its implementation
services.AddSingleton<IBlackholeCore, BlackholeCore>();

var serviceProvider = services.BuildServiceProvider();

// Resolve the IBlackholeCore service
var blackholeCore = serviceProvider.GetRequiredService<IBlackholeCore>();

Alternatively, if you are using a Host (for example, in a console application):

using Blackhole.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using var host = Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.AddSingleton<IBlackholeCore, BlackholeCore>();
        // Register other services
    })
    .Build();

// Resolve the IBlackholeCore service
var blackholeCore = host.Services.GetRequiredService<IBlackholeCore>();

Usage Examples

using Blackhole.Core;
using System;
using System.Threading.Tasks;

class Program
{
    private readonly IBlackholeCore _blackholeCore;

    public Program(IBlackholeCore blackholeCore)
    {
        _blackholeCore = blackholeCore;
    }

    static async Task Main(string[] args)
    {
        // Set up dependency injection
        var services = new ServiceCollection();
        services.AddSingleton<IBlackholeCore, BlackholeCore>();
        services.AddTransient<Program>();

        var serviceProvider = services.BuildServiceProvider();

        var program = serviceProvider.GetRequiredService<Program>();
        await program.Run();
    }

    public async Task Run()
    {
        // Discard unwanted data
        var disposableResource = new MemoryStream();
        _blackholeCore.Blackhole(disposableResource);
        Console.WriteLine("Blackhole method called successfully.");

        // Conditionally process data
        var result = _blackholeCore.EventHorizon(42, x => x > 40);
        Console.WriteLine($"EventHorizon result: {result}");

        // Compress string data
        byte[] compressed = _blackholeCore.Singularity("Hello, World!");
        Console.WriteLine($"Compressed data length: {compressed.Length}");

        // Add delay to operations
        var delayedResult = await _blackholeCore.TimeDilation("Time Dilation Test", 1000); // 1 second delay
        Console.WriteLine($"TimeDilation result: {delayedResult}");

        // Transform data
        var transformed = _blackholeCore.Wormhole(5, x => x * x);
        Console.WriteLine($"Wormhole result: {transformed}");

        // Execute parallel operations
        _blackholeCore.WarpDrive(() => Console.WriteLine("WarpDrive action executed."));

        // Synchronize objects
        var source = new SampleData { Id = 1, Name = "Source" };
        var target = new SampleData();
        _blackholeCore.QuantumEntanglement(source, target);
        Console.WriteLine($"QuantumEntanglement target data: Id={target.Id}, Name={target.Name}");

        // Revert to previous state
        var previousData = new SampleData { Id = 0, Name = "Previous" };
        var currentData = new SampleData { Id = 1, Name = "Current" };
        var timeTravelResult = _blackholeCore.TimeTravel(currentData, previousData);
        Console.WriteLine($"TimeTravel result: Id={timeTravelResult.Id}, Name={timeTravelResult.Name}");

        // Split string into characters
        var spaghettified = _blackholeCore.Spaghettify("Spaghettify");
        Console.WriteLine($"Spaghettify result: {string.Join(", ", spaghettified)}");

        // Create palindrome
        var lensResult = _blackholeCore.GravitationalLens("Lens");
        Console.WriteLine($"GravitationalLens result: {lensResult}");

        // Rotate string
        var kerrResult = _blackholeCore.KerrMetric("KerrMetric", 3);
        Console.WriteLine($"KerrMetric result: {kerrResult}");

        // Insert separators
        var cosmicResult = _blackholeCore.CosmicExpansion("Expand", "-");
        Console.WriteLine($"CosmicExpansion result: {cosmicResult}");

        // Character-level transformation
        var planckResult = _blackholeCore.PlanckProcessor("Planck", c => char.ToUpper(c));
        Console.WriteLine($"PlanckProcessor result: {planckResult}");

        // Simulate data evaporation
        Console.WriteLine("HawkingRadiation results:");
        foreach (var state in _blackholeCore.HawkingRadiation("Hawking"))
        {
            Console.WriteLine(state);
        }

        // Encode to Base64
        var hyperspaceResult = _blackholeCore.Hyperspace("Hyperspace");
        Console.WriteLine($"Hyperspace result: {hyperspaceResult}");

        // Recover or transform data
        int infoParadoxResult = _blackholeCore.InformationParadox(10, x => x * 2);
        Console.WriteLine($"InformationParadox result: {infoParadoxResult}");

        // Collapse data and transform
        string collapseResult = _blackholeCore.SingularityCollapse("Collapse", s => new string(s.Reverse().ToArray()));
        Console.WriteLine($"SingularityCollapse result: {collapseResult}");

        // Perform SIMD operations
        float[] floatArray = { 1.0f, 2.0f, 3.0f, 4.0f };
        float scalar = 2.0f;
        var quantumResult = _blackholeCore.QuantumAccelerator(floatArray, scalar, VectorOperation.Multiply);
        Console.WriteLine($"QuantumAccelerator result: {string.Join(", ", quantumResult)}");
    }
}

class SampleData
{
    public int Id { get; set; }
    public string Name { get; set; }
}

Note

  • The IBlackholeCore interface defines all the methods available in the library.
  • The BlackholeCore class is the concrete implementation of IBlackholeCore.
  • Dependency injection is used to inject IBlackholeCore into your classes, promoting decoupled and testable code.
  • You can set up dependency injection using Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.Hosting.

Requirements

  • .NET 6.0 or higher

License

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

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.5 102 11/27/2024

Upgrade