private static void HandleCreateOperatorCode(object sender, OperatorHints.CreateOperatorCodeEventArgs e) { if (!e.ShouldITryToCreate(nameof(Def_Power_Length_LinearPowerLoss))) { return; } e.Result.Comment = e.Input.DebugIs; var input = e.Input; var result = e.Result; if (input.Is <ValueA, ValueB, ValueC>("/")) { e.SetHandled(); result.SetComment(); result.Comment += " " + nameof(Def_Power_Length_LinearPowerLoss); result.WithResultUnit <UnitC>( $"{ValueA.FirstLower()}.Unit", $"{ValueB.FirstLower()}.Unit"); return; } if (input.Is <ValueC, ValueB, ValueA>("*")) { e.SetHandled(); result.SetComment(); result.Comment += " " + nameof(Def_Power_Length_LinearPowerLoss); result.AddVariable("tmp", $"{ValueC.FirstLower()}.Unit"); result.AddVariable("resultUnit", "tmp.CounterUnit"); result.AddVariable("lengthUnit", "tmp.DenominatorUnit"); result.ConvertRight("lengthUnit"); result.ResultUnit = "resultUnit"; } }
/// <summary> /// Reads the JSON representation of the object. /// </summary> /// <param name="reader">The JsonReader to read from.</param> /// <param name="objectType">Type of the object.</param> /// <param name="existingValue">The existing value of object being read.</param> /// <param name="serializer">The calling serializer.</param> public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.ValueType == typeof(string)) { if (objectType == typeof(LinearPowerLoss)) { return(LinearPowerLoss.Parse((string)reader.Value)); } } throw new NotImplementedException(); }
public bool Equals(LinearPowerLoss other) { return(Value == other.Value && !(Unit is null) && Unit.Equals(other.Unit)); }