protected virtual AuditLogEntry CreateEntry(SrmDocumentPair docPair) { var baseEntry = CreateBaseEntry(docPair); var rootProp = RootProperty.Create(typeof(T)); var objectInfo = new ObjectInfo <object>() .ChangeObjectPair(ObjectPair <object> .Create(null, this)) .ChangeRootObjectPair(docPair.ToObjectType()); var diffTree = DiffTree.FromEnumerator(Reflector <T> .EnumerateDiffNodes(docPair.ToObjectType(), rootProp, (T)this), DateTime.Now); if (diffTree.Root == null) { return(baseEntry); } var settingsString = Reflector <T> .ToString(objectInfo.RootObjectPair, diffTree.Root, ToStringState.DEFAULT.ChangeFormatWhitespace(true)); var entry = AuditLogEntry.CreateSettingsChangeEntry(docPair.OldDoc, diffTree, settingsString); return(baseEntry.Merge(entry)); }
/// <summary> /// Converts the given object to a string, showing each of its properties values. /// </summary> /// <param name="rootPair">old and new document, can be null</param> /// <param name="rootNode">diff node describing root object change</param> /// <param name="state">describes how to format the string</param> /// <returns>String representation</returns> public static string ToString(ObjectPair <object> rootPair, DiffNode rootNode, ToStringState state) { return(Reflector.ToString(rootPair, rootNode, null, state).Trim()); }
/// <summary> /// Converts the given object to a string, showing each of its properties values. /// </summary> /// <param name="rootPair">old and new document, can be null</param> /// <param name="docType">May determine whether human readable version requires "peptide"->"molecule" translation</param> // CONSIDER: does this belong in ToStringState? /// <param name="rootNode">diff node describing root object change</param> /// <param name="state">describes how to format the string</param> /// <returns>String representation</returns> public static string ToString(ObjectPair <object> rootPair, SrmDocument.DOCUMENT_TYPE docType, DiffNode rootNode, ToStringState state) { return(Reflector.ToString(rootPair, docType, rootNode, null, state).Trim()); }