示例#1
0
        public static string ToString(ObjectPair <object> rootPair, T obj, ToStringState state)
        {
            var objectInfo = new ObjectInfo <object>().ChangeNewObject(obj)
                             .ChangeRootObjectPair(rootPair ?? ObjectPair <object> .Create(null, null));
            var rootProp = RootProperty.Create(typeof(T));

            var enumerator = EnumerateDiffNodes(objectInfo, rootProp, true);

            return(ToString(objectInfo.ParentObjectPair, DiffTree.FromEnumerator(enumerator, DateTime.Now).Root, state));
        }
示例#2
0
        /// <summary>
        /// Compares the settings objects of the given documents and creates an entry
        /// for the differences
        /// </summary>
        /// <param name="documentPair">The pair of documents to compare</param>
        /// <returns>A log entry containing the changes</returns>
        public static AuditLogEntry SettingsLogFunction(SrmDocumentPair documentPair)
        {
            var property = RootProperty.Create(typeof(SrmSettings), "Settings"); // Not L10N
            var objInfo  = new ObjectInfo <object>(documentPair.OldDoc.Settings, documentPair.NewDoc.Settings,
                                                   documentPair.OldDoc, documentPair.NewDoc, documentPair.OldDoc, documentPair.NewDoc);

            var tree = DiffTree.FromEnumerator(Reflector <SrmSettings> .EnumerateDiffNodes(objInfo, property, false));

            return(tree.Root != null?CreateSettingsChangeEntry(documentPair.OldDoc, tree) : null);
        }
示例#3
0
        public static AuditLogEntry DiffDocNodes(MessageType action, SrmDocumentPair documentPair, params object[] actionParameters)
        {
            var property = RootProperty.Create(typeof(Targets));
            var objInfo  = new ObjectInfo <object>(documentPair.OldDoc.Targets, documentPair.NewDoc.Targets,
                                                   documentPair.OldDoc, documentPair.NewDoc, documentPair.OldDoc, documentPair.NewDoc);

            var diffTree = DiffTree.FromEnumerator(Reflector <Targets> .EnumerateDiffNodes(objInfo, property, false), DateTime.Now);

            if (diffTree.Root != null)
            {
                var message = new MessageInfo(action, actionParameters);
                var entry   = CreateSettingsChangeEntry(documentPair.OldDoc, diffTree)
                              .ChangeUndoRedo(message);
                return(entry);
            }

            return(null);
        }
示例#4
0
        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));
        }