Exemple #1
0
 public abstract LogMessage ToMessage(PropertyName name, LogLevel level, bool allowReflection);
Exemple #2
0
 public DiffNodeNamePair ChangeName(PropertyName name)
 {
     return(ChangeProp(ImClone(this), im => im.Name = name));
 }
Exemple #3
0
 public DiffNodeNamePair(DiffNode node, PropertyName name, bool allowReflection)
 {
     Node            = node;
     Name            = name;
     AllowReflection = allowReflection;
 }
Exemple #4
0
 public static LogMessage ToMessage(DiffNode node, PropertyName name, LogLevel level, bool allowReflection)
 {
     return(node.ToMessage(name, level, allowReflection));
 }
Exemple #5
0
        public List <DiffNodeNamePair> FindAllLeafNodes(DiffTree tree, PropertyName name, bool allowReflection, DiffNode parentNode = null)
        {
            var result = new List <DiffNodeNamePair>();

            var propertyNameString = Property.GetName(tree.Root, this, parentNode);

            var isName = false;
            // Collection elements should be referred to by their name or string representation
            var propName = IsCollectionElement
                ? new PropertyElementName(ObjectToString(allowReflection, Objects.FirstOrDefault(o => o != null), out isName))
                : (Property.IsTab ? new PropertyTabName(propertyNameString) : new PropertyName(propertyNameString));

            // The name can not be ignored if the node is a collection change (since then the child nodes of the collection change
            // have the same attribute as the collection change node)
            var canIgnoreName = (Property.IgnoreName && !IsCollectionElement);

            if (!canIgnoreName)
            {
                name = name != null?name.SubProperty(propName) : propName;
            }

            // We can't display sub changes of an element if it's unnamed, so we display its
            // string representation as a change
            if (IsCollectionElement && !isName && !canIgnoreName)
            {
                result.Add(new DiffNodeNamePair(this, name, allowReflection));
                return(result);
            }

            var obj           = Objects.FirstOrDefault();
            var isNamedChange = IsFirstExpansionNode || (obj != null && AuditLogObject.GetAuditLogObject(obj).IsName) &&
                                Expanded && !canIgnoreName;

            if (isNamedChange)
            {
                result.Add(new DiffNodeNamePair(this, name, allowReflection));
            }

            if (Nodes.Count == 0)
            {
                if (!isNamedChange)
                {
                    result.Add(new DiffNodeNamePair(this, name, allowReflection));
                }
            }
            else
            {
                var collectionPropDiffNode = this as CollectionPropertyDiffNode;
                if (collectionPropDiffNode != null && collectionPropDiffNode.RemovedAll)
                {
                    result.Add(new DiffNodeNamePair(this, name, allowReflection));
                }
                else
                {
                    foreach (var n in Nodes)
                    {
                        result.AddRange(n.FindAllLeafNodes(tree, name, allowReflection, this));
                    }
                }
            }

            return(result);
        }