protected override MutableObject Mutate(MutableObject mutable) { foreach (var entry in AxisKey.GetEntries(mutable)) { TargetField.SetValue(OutputStack.TransformValue( ConversionFunc( InputStack.TransformValue(AxisKey.GetValue(entry)), entry)), entry); } return(mutable); }
protected override MutableObject Mutate(MutableObject mutable) { foreach (var entry in AxisKey.GetEntries(mutable)) { TargetField.SetValue(OutputStack.TransformValue( string.Compare(InputStack.TransformValue(AxisKey.GetValue(entry)), InputStack.TransformValue(ToMatch.GetValue(entry)), StringComparison.InvariantCultureIgnoreCase) == 0), entry); } return(mutable); }
protected override MutableObject Mutate(MutableObject mutable) { var entries = AxisKey.GetEntries(mutable); var foundStrings = new HashSet <T>(); // identify the set of unique keys foreach (var entry in entries) { var axisKey = InputStack.TransformValue(AxisKey.GetValue(entry)); if (!foundStrings.Contains(axisKey)) { foundStrings.Add(axisKey); } } // DO NOT sort the keys //var sortedKeys = foundStrings.ToList(); //sortedKeys.Sort(); // index the values var axisValues = GroupId.GetFirstValue(mutable) == "" ? new Dictionary <T, int>() : DataShare.ContainsKey(GroupId.GetFirstValue(mutable)) ? DataShare[GroupId.GetFirstValue(mutable)] : new Dictionary <T, int>(); int i = 0; foreach (var key in foundStrings) //sortedKeys { axisValues[key] = OutputStack.TransformValue(i++); } // finally, write the new axis value into each entry entries = AxisKey.GetEntries(mutable); foreach (var entry in entries) { IndexAxis.SetValue( axisValues[InputStack.TransformValue(AxisKey.GetValue(entry))], entry); } if (GroupId.GetFirstValue(mutable) != "") { DataShare[GroupId.GetFirstValue(mutable)] = axisValues; } return(mutable); }