protected bool CopyFromPins(Message message, int index, bool checkPinForChange = false) { var hasCopied = false; foreach (string fieldName in FPins.Keys) { // don't change if pin data still the same if (!checkPinForChange || FPins[fieldName].ToISpread().IsChanged) { var pinSpread = FPins[fieldName].ToISpread(); var invalidBin = pinSpread == null || pinSpread.SliceCount == 0 || pinSpread[0] == null; if (invalidBin) { if (message.Fields.Contains(fieldName)) { message[fieldName].Clear(); // to be or not to be? hasCopied = true; } } else { var bin = pinSpread[index] as IEnumerable; var type = Formular[fieldName].Type; // don't change if pin data equals the message data, because doing so will flag the message dirty. if (!message.Fields.Contains(fieldName) || !message[fieldName].Equals(bin)) { message.AssignFrom(fieldName, bin, type); hasCopied = true; } } } } return hasCopied; }