New Break instances for switchCase

This commit is contained in:
Niko Martini 2019-07-17 16:37:38 +02:00
parent 64ba37e9c6
commit fe3febe660

View file

@ -2,27 +2,33 @@ function ConvertTo-Byte()
{ {
param( param(
[single]$Value, [single]$Value,
[string]$Unit [string]$Unit #Validation PT PetaByte
); );
switch ($Unit) { switch ($Unit) {
B { Byte {
$result = $Value; $result = $Value;
break;
} }
KB { KiloByte {
$result = ($Value * [math]::Pow(10, 3)); $result = ($Value * [math]::Pow(10, 3));
break;
} }
MB { MegaByte {
$result = ($Value * [math]::Pow(10, 6)); $result = ($Value * [math]::Pow(10, 6));
break;
} }
GB { GigaByte {
$result = ($Value * [math]::Pow(10, 9)); $result = ($Value * [math]::Pow(10, 9));
break;
} }
TB { TeraByte {
$result = ($Value * [math]::Pow(10, 12)); $result = ($Value * [math]::Pow(10, 12));
break;
} }
PB { PetaByte {
$result = ($Value * [math]::Pow(10, 15)); $result = ($Value * [math]::Pow(10, 15));
break;
} }
Default {} Default {}
} }
@ -37,23 +43,29 @@ function ConvertTo-KiloByte()
); );
switch ($Unit) { switch ($Unit) {
B { Byte {
$result = ($Value / 1000); $result = ($Value / 1000);
break;
} }
KB { KiloByte {
$result = $Value; $result = $Value;
break;
} }
MB { MegaByte {
$result = ($Value * [math]::Pow(10, 3)); $result = ($Value * [math]::Pow(10, 3));
break;
} }
GB { GigaByte {
$result = ($Value * [math]::Pow(10, 6)); $result = ($Value * [math]::Pow(10, 6));
break;
} }
TB { TeraByte {
$result = ($Value * [math]::Pow(10, 9)); $result = ($Value * [math]::Pow(10, 9));
break;
} }
PB { PetaByte {
$result = ($Value * [math]::Pow(10, 12)); $result = ($Value * [math]::Pow(10, 12));
break;
} }
Default {} Default {}
} }
@ -69,23 +81,29 @@ function ConvertTo-MegaByte()
); );
switch ($Unit) { switch ($Unit) {
B { Byte {
$result = ($Value / [math]::Pow(10, 6)); $result = ($Value / [math]::Pow(10, 6));
break;
} }
KB { KiloByte {
$result = ($Value / [math]::Pow(10, 3)); $result = ($Value / [math]::Pow(10, 3));
break;
} }
MB { MegaByte {
$result = $Value; $result = $Value;
break;
} }
GB { GigaByte {
$result = ($Value * [math]::Pow(10, 3)); $result = ($Value * [math]::Pow(10, 3));
break;
} }
TB { TeraByte {
$result = ($Value * [math]::Pow(10, 6)); $result = ($Value * [math]::Pow(10, 6));
break;
} }
PB { PetaByte {
$result = ($Value * [math]::Pow(10, 9)); $result = ($Value * [math]::Pow(10, 9));
break;
} }
Default {} Default {}
} }
@ -101,23 +119,29 @@ function ConvertTo-GigaByte()
); );
switch ($Unit) { switch ($Unit) {
B { Byte {
$result = ($Value / [math]::Pow(10, 9)); $result = ($Value / [math]::Pow(10, 9));
break;
} }
KB { KiloByte {
$result = ($Value / [math]::Pow(10, 6)) $result = ($Value / [math]::Pow(10, 6));
break;
} }
MB { MegaByte {
$result = ($Value / [math]::Pow(10, 3)); $result = ($Value / [math]::Pow(10, 3));
break;
} }
GB { GigaByte {
$result = $Value; $result = $Value;
break;
} }
TB { TeraByte {
$result = ($Value * [math]::Pow(10, 3)); $result = ($Value * [math]::Pow(10, 3));
break;
} }
PB { PetaByte {
$result = ($Value * [math]::Pow(10, 6)); $result = ($Value * [math]::Pow(10, 6));
break;
} }
Default {} Default {}
} }
@ -133,23 +157,29 @@ function ConvertTo-TeraByte()
); );
switch ($Unit) { switch ($Unit) {
B { Byte {
$result = ($Value / [math]::Pow(10, 12)); $result = ($Value / [math]::Pow(10, 12));
break;
} }
KB { KiloByte {
$result = ($Value / [math]::Pow(10, 9)); $result = ($Value / [math]::Pow(10, 9));
break;
} }
MB { MegaByte {
$result = ($Value / [math]::Pow(10, 6)); $result = ($Value / [math]::Pow(10, 6));
break;
} }
GB { GigaByte {
$result = ($Value / [math]::Pow(10, 3)); $result = ($Value / [math]::Pow(10, 3));
break;
} }
TB { TeraByte {
$result = $Value; $result = $Value;
break;
} }
PB { PetaByte {
$result = ($Value * [math]::Pow(10, 3)); $result = ($Value * [math]::Pow(10, 3));
break;
} }
Default {} Default {}
} }
@ -165,23 +195,29 @@ function ConvertTo-PetaByte()
); );
switch ($Unit) { switch ($Unit) {
B { Byte {
$result = ($Value / [math]::Pow(10, 15)); $result = ($Value / [math]::Pow(10, 15));
break;
} }
KB { KiloByte {
$result = ($Value / [math]::Pow(10, 12)); $result = ($Value / [math]::Pow(10, 12));
break;
} }
MB { MegaByte {
$result = ($Value / [math]::Pow(10, 9)); $result = ($Value / [math]::Pow(10, 9));
break;
} }
GB { GigaByte {
$result = ($Value / [math]::Pow(10, 6)); $result = ($Value / [math]::Pow(10, 6));
break;
} }
TB { TeraByte {
$result = ($Value / [math]::Pow(10, 3)); $result = ($Value / [math]::Pow(10, 3));
break;
} }
PB { PetaByte {
$result = $Value; $result = $Value;
break;
} }
Default {} Default {}
} }