#pragma warning restore public void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { SpreadMax = 0; } else { SpreadMax = FInput.SliceCount; } if (SpreadMax == 0) { FOutput.FlushNil(); return; } if (!FInput.IsChanged) { return; } var result = FInput.OrderBy(message => message.TimeStamp.UniversalTime); FOutput.FlushResult(result); }
#pragma warning restore public override void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { SpreadMax = 0; } else { SpreadMax = FInput.SliceCount; } if (SpreadMax == 0) { FOutput.FlushNil(); return; } if (!FInput.IsChanged && !FUseFields.IsChanged) { return; } FOutput.SliceCount = 0; var fieldNames = FUseFields[0]; if (fieldNames.IsAnyInvalid()) { FOutput.FlushResult(FInput); } else { var ordered = FInput.OrderBy(message => message[fieldNames[0].Name][0]); for (int i = 1; i < fieldNames.SliceCount; i++) { ordered = ordered.ThenBy(message => message[fieldNames[i].Name][0]); } FOutput.FlushResult(ordered); } }
public override void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { if (FOutput.SliceCount > 0) { FOutput.FlushNil(); } return; } SpreadMax = FInput.SliceCount; if (!FInput.IsChanged && !FUseFields.IsChanged && !FDescending.IsChanged) { return; } if (FUseFields.IsAnyInvalid()) { FOutput.FlushResult(FInput); return; } // flatten, to ignore binsize. optimize potential! List <EnumEntry> fieldNames = new List <EnumEntry>(); foreach (var bin in FUseFields) { foreach (var entry in bin) { if (entry != null && !fieldNames.Contains(entry)) { fieldNames.Add(entry); } } } IOrderedEnumerable <Message> ordered = FInput.OrderBy(message => 1); // noop sort to "cast" into interface for (int i = 0; i < fieldNames.Count; i++) { var fieldName = fieldNames[i].Name; Func <Message, object> deleg; switch (fieldName) { case "Topic": deleg = message => message.Topic; break; case "TimeStamp": deleg = message => message.TimeStamp.UniversalTime; break; default: // todo: retrieve a proper default for this typed field object fallBack = 1; // noop, when not possible deleg = message => message[fieldName].IsAnyInvalid() ? fallBack : message[fieldName][0]; break; } if (FDescending[i]) { ordered = ordered.ThenByDescending(deleg); } else { ordered = ordered.ThenBy(deleg); } } FOutput.FlushResult(ordered); }