public virtual Differences VisitSecurityAttribute(SecurityAttribute attribute1, SecurityAttribute attribute2){
      Differences differences = new Differences(attribute1, attribute2);
      if (attribute1 == null || attribute2 == null){
        if (attribute1 != attribute2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      SecurityAttribute changes = (SecurityAttribute)attribute2.Clone();
      SecurityAttribute deletions = (SecurityAttribute)attribute2.Clone();
      SecurityAttribute insertions = (SecurityAttribute)attribute2.Clone();

      if (attribute1.Action == attribute2.Action) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      AttributeList attrChanges, attrDeletions, attrInsertions;
      Differences diff = this.VisitAttributeList(attribute1.PermissionAttributes, attribute2.PermissionAttributes, out attrChanges, out attrDeletions, out attrInsertions);
      if (diff == null){Debug.Assert(false); return differences;}
      changes.PermissionAttributes = attrChanges;
      deletions.PermissionAttributes = attrDeletions;
      insertions.PermissionAttributes = attrInsertions;
      differences.NumberOfDifferences += diff.NumberOfDifferences;
      differences.NumberOfSimilarities += diff.NumberOfSimilarities;

      if (attribute1.PermissionAttributes == null && attribute2.PermissionAttributes == null &&
        attribute1.SerializedPermissions == attribute2.SerializedPermissions) differences.NumberOfSimilarities++; else differences.NumberOfDifferences++;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Exemple #2
0
 public override SecurityAttribute VisitSecurityAttribute(SecurityAttribute attribute)
 {
     if (attribute == null) return null;
     return base.VisitSecurityAttribute((SecurityAttribute)attribute.Clone()); ;
 }