Beispiel #1
0
        public static PartConversion Create(Unit unit, PowerPart c1, PowerPart c2)
        {
            string name;

            if (c1.Power > 0 &&
                c2.Power > 0)
            {
                name = $"{c1.FirstName}{c2.LastName}";
            }
            else if (c1.Power > 0 && c2.Power < 0)
            {
                name = $"{c1.FirstName}Per{c2.LastName}";
            }
            else
            {
                throw new ArgumentOutOfRangeException();
            }

            var symbolAndPowers = c1.AsSymbolAndPowers().Concat(c2.AsSymbolAndPowers());
            var symbol          = symbolAndPowers.AsSymbol();
            var factor          = c1.Factor * c2.Factor;

            // hacking unit like this for simpler serialization
            return(new PartConversion(name, symbol, factor)
            {
                unit = unit
            });
        }
Beispiel #2
0
        public static PartConversion Create(Unit unit, PowerPart c1)
        {
            var name   = c1.FirstName;
            var symbol = c1.Symbol;
            var factor = c1.Factor;

            return(new PartConversion(name, symbol, factor)
            {
                unit = unit
            });                                                              // hacking unit like this for simpler serialization
        }