Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB.net Unit Syntax #1

Open
AdamSpeight2008 opened this issue Nov 14, 2017 · 0 comments
Open

VB.net Unit Syntax #1

AdamSpeight2008 opened this issue Nov 14, 2017 · 0 comments

Comments

@AdamSpeight2008
Copy link
Owner

AdamSpeight2008 commented Nov 14, 2017

If were to add Units Of Measure to the VB.Net. What would the syntax look like for defining them.

Namespace Units
  Namespace Mass
    Abstract MassUnit : Inherits AbstractUnits
    End Unit

    Unit Mass : Inherits MassUnits("kg","kilograms")
    End Unit
  End Namespace

  Namespace LuminousIntensiry
    Abstract LuminousIntensityUnits : Inherits AbstractUnits
    End Unit
  
    Unit Candela : Inherits LuminousIntensity("cd","candela")
    End Unit
  End Namespace

  Namespace Distance
    Abstract DistanceUnits : Inherits AbstractUnits
    End Unit

    Unit MilliMetres Inherits DistanceUnits("mm","millimetres")
      Metres = Value / 1000D
    End Units

    Unit Metres Inherits DistanceUnits("m","metres")
       Millimetres = Value * 1000D
    End Units
  End Namespace

  Namespace Time
    Abstract Unit TimeUnits : Inherits AbstractUnits
    End Unit
    
    Unit Seconds : Inherits TimeUnits("s","seconds")
      Minutes = Value / 60D
    End Unit

    Unit Minute : Inherits TimeUnits("min","minutes")
      Seconds = Value * 60D
    End Units
  End Namespace

  Namespace Temperature
    Abstract Unit TemperatureUnits : Inherits AbstractUnits
    End Unit
    Unit Kelvin : Inherits TemperatureUnits("K","kelvins")
      Celsius    = Value + 273.15D
      Fahrenheit = ( (Value - 32D) * (5D/9D) ) + 273.15D
    End Unit
    Unit Celsius : Inherits TemperatureUnits("C","Celcius")
      Kelvin     = Value - 273.15D
      Fahrenheit = (Value * (9D/5D)) + 32D
    End Unit
    Unit Fahrenheit : Inherits TempatureUnits("F","Fahrenheit ")
      Celsius = ( (Value - 32D) * (5D/9D) )
      Kelvin  = ( (Value -273.15D) * (9D/5D) ) + 32D
    End Unit
End Namespace

This would compile and expand out to a set class, similar what is declared in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant