QuantityRatio attribute
- Dominant language
- C#
- Stars
- 247
- Forks
- 47
- Avg merge
- 7d 7h
- Merged PRs (30d)
- 4
Description
#### Description:
Idea to add an attribute to help generate an attribute that is a ratio of two other attributes. Something like:
```
using BH.oM.Base;
using BH.oM.Base.Attributes;
using System;
using System.ComponentModel;
namespace BH.oM.Quantities.Attributes
{
[Description("Attribute describing a ratio between two quantities")]
public class QuantityRatioAttribute : QuantityAttribute, IImmutable
where T1 : QuantityAttribute, new()
where T2 : QuantityAttribute, new()
{
/***************************************************/
/**** Properties ****/
/***************************************************/
[Description("Length dimension")]
public override int L { get; } = t1.L - t2.L;
[Description("Mass dimension")]
public override int M { get; } = t1.M - t2.M;
[Description("Time dimension")]
public override int T { get; } = t1.T - t2.T;
[Description("Electric current dimension")]
public override int I { get; } = t1.I - t2.I;
[Description("Temperature dimension")]
public override int Θ { get; } = t1.Θ - t2.Θ;
[Description("Amount of substance dimension")]
public override int N { get; } = t1.N - t2.N;
[Description("Luminous intensity dimension")]
public override int J { get; } = t1.J - t2.J;
[Description("SI derived unit symbol")]
public override string SIUnit { get; } = $"({t1.SIUnit}) / ({t2.SIUnit})";
/***************************************************/
/**** Private Fields ****/
/***************************************************/
private static readonly T1 t1 = new T1();
private static readonly T2 t2 = new T2();
/***************************************************/
}
}
```
Could then be used on a property like:
```
[QuantityRatio]
[Description("Climate change - total relating to the Raw Material Supply module in the Product stage.")]
public override double A1 { get; protected set; }
```
This cannot however requires c#11 and crashes on trying to access it when run in a framework runtime. Tested running in Grasshopper for Rhino 8 this works, but in Excel as well as Grasshopper for Rhino7 this is crashing out when trying to access the quantity attribute.
Raising this as idea to be explored in the future if/when we can safely increase the langue version.
Contributor guide
Assessment
This issue has not been assessed yet.