Esempio n. 1
0
        public override LogMessage ToMessage(PropertyName name, LogLevel level, bool allowReflection)
        {
            if (!RemovedAll)
            {
                return(base.ToMessage(name, level, allowReflection));
            }

            return(new LogMessage(level, MessageType.removed_all, DocType, Expanded,
                                  name.ToString()));
        }
Esempio n. 2
0
        public override LogMessage ToMessage(PropertyName name, LogLevel level, bool allowReflection)
        {
            var value = ObjectToString(allowReflection);

            if (IsCollectionElement)
            {
                name = name.Parent;
            }

            return(new LogMessage(level,
                                  Removed ? MessageType.removed_from : Expanded?MessageType.contains: MessageType.added_to, DocType,
                                  Expanded, name.ToString(), value));
        }
Esempio n. 3
0
        public override LogMessage ToMessage(PropertyName name, LogLevel level, bool allowReflection)
        {
            var newIsName = false;
            var oldIsName = false;

            // new-/oldValue can are only null if reflection is not allowed and their AuditLogText uses reflection
            var stringPair = Value.Transform(
                obj => obj == null ? LogMessage.MISSING : ObjectToString(allowReflection, obj, out oldIsName),
                obj => obj == null ? LogMessage.MISSING : ObjectToString(allowReflection, obj, out newIsName));

            var sameValue = stringPair.Equals();

            if (Expanded && level == LogLevel.all_info)
            {
                return(new LogMessage(level, MessageType.is_, DocType,
                                      Expanded, name.ToString(), stringPair.NewObject));
            }

            // If the string representations are the same, we don't want to show either of them
            if (!sameValue)
            {
                // If one of them is a name, the other also has to be a name or its value is null, in which
                // case it gets set to "Missing"
                if (oldIsName || newIsName || (level == LogLevel.all_info && !Expanded))
                {
                    return(new LogMessage(level, MessageType.changed_from_to, DocType, Expanded,
                                          name.ToString(), stringPair.OldObject, stringPair.NewObject));
                }
                else if (stringPair.NewObject != null)
                {
                    return(new LogMessage(level, MessageType.changed_to, DocType, Expanded,
                                          name.ToString(), stringPair.NewObject));
                }
            }

            return(new LogMessage(level, MessageType.changed, DocType, Expanded,
                                  name.ToString()));
        }