Imani.Solutions.Core 0.1.0

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

// Install Imani.Solutions.Core as a Cake Tool
#tool nuget:?package=Imani.Solutions.Core&version=0.1.0                

Imani.Solutions.Core.DotNet version 0.1.0

DotNet Core C# API solutions

Imani.Solutions.Core.Util

ConfigSettings

This object supports geting properties for environment variables or input arguments (prefix with --PROPERTY_NAME)

Create a new instance.

ConfigSettings  config = new ConfigSettings();

Setting property with an environment variable (ex: KAFKA_BOOTSTRAP_SERVERS)

# Example for UNIT/LINUX
export KAFKA_BOOTSTRAP_SERVERS=localhost

Or setting property with an input argument

dotnet run --KAFKA_BOOTSTRAP_SERVERS=localhost

Get a string property by name (throws an argument exception if the property does not exist)

string servers = config.GetProperty("KAFKA_BOOTSTRAP_SERVERS");

Use a default value if the property does not exist.

string servers = config.GetProperty("KAFKA_BOOTSTRAP_SERVERS","localhost");

Get an integer property

int port = config.GetPropertyInteger("KAFKA_PORT");

Use a default integer if the property not set.

int port = config.GetPropertyInteger("KAFKA_PORT",9092);

Get a boolean value

bool actual = new ConfigSettings().GetPropertyBoolean("BOOL_PROP");

Get a decrypted secret

string secret = this.subject.GetPropertySecret("MYSECRET");

Get a decrypted password secret

char[] password = this.subject.GetPropertyPassword("MYPASSWORD");
Passwords

You must set the salt environment variable CRYPTION_KEY.

# example
export CRYPTION_KEY=xQwdSd23sdsd23

Generate encrypted password

var encrypted= config.EncryptPassword(expected);

Set encrypted password in the environment variable (along with salt key).

# example
export CRYPTION_KEY=xQwdSd23sdsd23
export MYPASSWORD=outputFrom[config.EncryptPassword(expected)]

Get encrypted password by environment variable named MYPASSWORD

char [] password = config.GetPropertyPassword("MYPASSWORD");

Text

Example usage code

 Text text = new Text();
 IDictionary<string, string> map = new Dictionary<string, string>();

 map["firstName"] = "Gregory";
 map["lastName"] = "Green";

 var actual = textt.Format("${firstName} ${lastName}", map);

 Assert.Equal("Gregory Green",actual);

Cryption

Cryption subject = new Cryption(key);
string actual = subject.EncryptText(expected);
Assert.AreEqual(expected, subject.DecryptText(actual));

Imani.Solutions.Core.API.NET

Http

GET

string url = "http://www.TheRevelationSquad.com";

var subject =new Http();
var httpResponse = subject.Get(url);
Assert.IsNotNull(httpResponse);
Assert.AreEqual(200,httpResponse.StatusCode);
Console.WriteLine("HTML:"+httpResponse.Body);

GET

string url = "http://www.TheRevelationSquad.com";

var subject =new Http();
var httpResponse = subject.Get(url);
Assert.IsNotNull(httpResponse);
Assert.AreEqual(200,httpResponse.StatusCode);
Console.WriteLine("HTML:"+httpResponse.Body);

POST

string url = "http://www.TheRevelationSquad.com";


string payload = "{}";
string contentType = "application/json";
var httpResponse = subject.Post(url,payload,contentType);
Assert.IsNotNull(httpResponse);

Assert.AreEqual(200,httpResponse.StatusCode);
Console.WriteLine("HTML:"+httpResponse.Body);

Imani.Solutions.Core.API.Serialization

JsonSerde

Serialization

var subject = new JsonSerde<DomainQa>();
DomainQa expected = new DomainQa(){
    Id = "hello"
};
           
var actualSerialized = subject.Serialize(expected);
Assert.IsNotNull(actualSerialized);

var actual = subject.Deserialize(actualSerialized);
Assert.AreEqual(expected.Id,actual.Id);

Deserialization

var subject = new JsonSerde<DomainQa>();
 
string json ="{\"Id\" : \"You\"}";
DomainQa actual = subject.Deserialize(json);
Assert.AreEqual("You",actual.Id);

Packaging

Pre steps

  • Update Imani.Solutions.Core.nuspec version
  • Update Imani.Solutions.Core.csproj
dotnet build -c Release
dotnet pack -c Release
nuget pack Imani.Solutions.Core.csproj -properties Configuration=Release -Version 0.1.0
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has 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
0.1.0 951 2/17/2022
0.0.9 897 1/31/2021
0.0.8 944 1/1/2021
0.0.7 906 12/18/2020
0.0.1 2,339 8/15/2020

Configuration secrets and text generation .