private static void SetVersionHistory(SavingAction action, Node node, IEnumerable <NodeHead.NodeVersion> versionHistory) { var lastMajorVer = versionHistory.Where(v => v.VersionNumber.Minor == 0 && v.VersionNumber.Status == VersionStatus.Approved).LastOrDefault(); var lastMinorVer = versionHistory.LastOrDefault(); var head = NodeHead.CreateFromNode(node, lastMinorVer.VersionId, lastMajorVer == null ? 0 : lastMajorVer.VersionId); var fieldInfo = head.GetType().GetField("_versions", BindingFlags.NonPublic | BindingFlags.Instance); fieldInfo.SetValue(head, versionHistory); var methodInfo = action.GetType().GetMethod("SetNodeHead", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(NodeHead) }, null); methodInfo.Invoke(action, new object[] { head }); }
private static void SetVersionHistory(SavingAction action, Node node, IEnumerable<NodeHead.NodeVersion> versionHistory) { var lastMajorVer = versionHistory.Where(v => v.VersionNumber.Minor == 0 && v.VersionNumber.Status == VersionStatus.Approved).LastOrDefault(); var lastMinorVer = versionHistory.LastOrDefault(); var head = NodeHead.CreateFromNode(node, lastMinorVer.VersionId, lastMajorVer == null ? 0 : lastMajorVer.VersionId); var fieldInfo = head.GetType().GetField("_versions", BindingFlags.NonPublic | BindingFlags.Instance); fieldInfo.SetValue(head, versionHistory); var methodInfo = action.GetType().GetMethod("SetNodeHead", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(NodeHead) }, null); methodInfo.Invoke(action, new object[] { head }); }