relay-dev - Relay.Energy 1.0.7
A small library of utilities that are useful in the energy industry
PM> Install-Package Relay.Energy -Version 1.0.7 -Source https://www.myget.org/F/relay-dev/api/v3/index.json
> nuget.exe install Relay.Energy -Version 1.0.7 -Source https://www.myget.org/F/relay-dev/api/v3/index.json
> dotnet add package Relay.Energy --version 1.0.7 --source https://www.myget.org/F/relay-dev/api/v3/index.json
source https://www.myget.org/F/relay-dev/api/v3/index.json
nuget Relay.Energy ~> 1.0.7
Copy to clipboard
> choco install Relay.Energy --version 1.0.7 --source https://www.myget.org/F/relay-dev/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "relay-dev" -SourceLocation "https://www.myget.org/F/relay-dev/api/v2"
Install-Module -Name "Relay.Energy" -RequiredVersion "1.0.7" -Repository "relay-dev"
Copy to clipboard
Energy
Introduction
Energy is a small library of utilities that are useful in the energy industry.
Getting Started
Installation
Follow the instructions below to install this NuGet package into your project:
.NET Core CLI
dotnet add package Relay.Energy
Package Manager Console
Install-Package Relay.Energy
Latest releases
Latest releases and package version history can be found on NuGet.
Build and Test
Follow the instructions below to build and test this project:
Build
.NET Core CLI
dotnet build
Test
.NET Core CLI
dotnet test
Usage
Data Structures
The data structures in this library represent energy dimensions. An energy dimension is an attribute pertaining to a record in a system built for the energy industry. Since these dimensions are fundamental to the business and used so frequently, it makes sense to standardize the way they are represented. Each energy dimension exposes the same set of properties which are derived from parsing an input string provided to the constructor. Some more fun facts about energy dimensions:
- The dimensions are standardized, immutable, lightweight structs
- String interpretation is flexible
- Different variations of the same data are considered when parsing input strings.
- This is valuable when a system interacts with several different vendors that represent the same attribute in different ways. For example, one vendor may represent an Electric account as 'E', while another uses 'Electric'.
- There are standard sets of static values exposed by each structure that represent valid values
- For example, the Commodity structure exposes static instances that represent Electric, Gas, Solar and Unrecognized (Unrecognized is available for all energy dimensions as a representation of an input string that couldn't be parsed).
- This allows you to use the structs similarly to the way you would use an enum
- Comparison amongst instances is simple
- The equivalency operators are overloaded for each dimension to support comparing dimensions of the same type to each other, and for comparing strings to a dimension.
Standardized fields
Each dimension contains everything needed to parse an input string and return it's standardized constituents.
private void StandardizedFieldsAreExposedForInstances()
{
var accountClass = new AccountClass("Residential");
Console.WriteLine(accountClass.Name);
Console.WriteLine(accountClass.Code);
Console.WriteLine(accountClass.DisplayName);
}
String Interpretation
Each dimension will sensibly parse the input string to account for variations in representation from different vendors.
private void InterpretationIsFlexibleForInputStrings()
{
var accountClass1 = new AccountClass("R");
var accountClass2 = new AccountClass("res");
var accountClass3 = new AccountClass("Resi");
var accountClass4 = new AccountClass("resi.");
Console.WriteLine(accountClass1.Name);
Console.WriteLine(accountClass2.Name);
Console.WriteLine(accountClass3.Name);
Console.WriteLine(accountClass4.Name);
}
Static Values
Each dimension exposes static instances for quick comparison and assignment.
private void StaticValuesRepresentValidValues()
{
AccountClass accountClassResidential = AccountClass.Residential;
AccountClass accountClassSmallCommercial = AccountClass.SmallCommercial;
AccountClass accountClassLargeCommercial = AccountClass.LargeCommercial;
Console.WriteLine(accountClassResidential.Name);
Console.WriteLine(accountClassSmallCommercial.Name);
Console.WriteLine(accountClassLargeCommercial.Name);
}
Equality Comparison
Each dimension can be compared for equality.
private void CompareForEquality()
{
AccountClass accountClassResidential1 = new AccountClass("Residential");
AccountClass accountClassResidential2 = new AccountClass("Residential");
AccountClass accountClassSmallCommercial = new AccountClass("Small Commercial");
bool isResidentialResidentialEquivalent = (accountClassResidential1 == accountClassResidential2);
bool isResidentialSmallCommercialEquivalent = (accountClassResidential1 == accountClassSmallCommercial);
Console.WriteLine("Is Residential Residential equivalent?: {0}", isResidentialResidentialEquivalent);
Console.WriteLine("Is Residential SmallCommercial equivalent?: {0}", isResidentialSmallCommercialEquivalent);
}
String Comparison
Each dimension can also be compared for equality using strings.
private void CompareForEqualityFromStrings()
{
AccountClass accountClassResidential1 = new AccountClass("Residential");
AccountClass accountClassResidential2 = new AccountClass("Residential");
AccountClass accountClassSmallCommercial = new AccountClass("Small Commercial");
bool isResidentialResidentialEquivalent = (accountClassResidential1 == "Residential");
bool isResidentialSmallCommercialEquivalent = (accountClassResidential2 == "Small Commercial");
bool isSmallCommercialSmallCommercialAbbreviationEquivalent = (accountClassSmallCommercial == "SC");
Console.WriteLine("Is Residential Residential equivalent?: {0}", isResidentialResidentialEquivalent);
Console.WriteLine("Is Residential SmallCommercial equivalent?: {0}", isResidentialSmallCommercialEquivalent);
Console.WriteLine("Is SmallCommercial SmallCommercial equivalent?: {0}", isSmallCommercialSmallCommercialAbbreviationEquivalent);
}
Services
Getting all dimensions
All dimensions can be returned as a collection.
private void AllDimensionsCanBeReturnedAsACollection()
{
IEnumerable<AccountClass> accountClasses = new EnergyDimensionService()
.GetAllAccountClasses();
foreach (AccountClass accountClass in accountClasses)
{
Console.WriteLine(accountClass);
}
}
More
There are several other variations not documented here. You can find a Console Application with these samples here.
Contribute
When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Initial release
- .NETStandard 2.1: 2.1.0.0
Ownerssferguson82 |
AuthorsScott Ferguson |
Project URLhttps://github.com/relay-dev/energy |
LicenseUnknown |
Info0 total downloads |
0 downloads for version 1.0.7 |
Download (11.74 KB) |
Found on the current feed only |
Package history
Version | Size | Last updated | Downloads | Mirrored? | |||
---|---|---|---|---|---|---|---|
1.0.7 | 11.74 KB | Sun, 12 Jul 2020 06:07:30 GMT | 0 |