public override bool Equals(object obj) { WorkflowProcess value = obj as WorkflowProcess; if (value != null) { List <object> listA = new List <object> { this.AccessLevel, this.AdhocOrdering, this.AdhocCompletionCondition, this.Adhoc, this.DefaultStartActivityId, this.DefaultStartActivitySetId, this.IsEnableInstanceCompensation, this.Id, this.Name, this.Object, this.ProcessHeader, this.ProcessType, this.RedefinableHeader, this.Status, this.IsEnableInstanceCompensation }; List <object> listB = new List <object> { value.AccessLevel, value.AdhocOrdering, value.AdhocCompletionCondition, value.Adhoc, value.DefaultStartActivityId, value.DefaultStartActivitySetId, value.IsEnableInstanceCompensation, value.Id, value.Name, value.Object, value.ProcessHeader, value.ProcessType, value.RedefinableHeader, value.Status, value.IsEnableInstanceCompensation }; if (!Utilities.IsListEqual <Activity>(this.Activities, value.Activities) || !Utilities.IsListEqual <ActivitySet>(this.ActivitySets, value.ActivitySets) || !Utilities.IsListEqual <Application>(this.Applications, value.Applications) || !Utilities.IsListEqual <Assignment>(this.Assignments, value.Assignments) || !Utilities.IsListEqual <DataField>(this.DataFields, value.DataFields) || !Utilities.IsListEqual <ExtendedAttribute>(this.ExtendedAttributes, value.ExtendedAttributes) || !Utilities.IsListEqual <FormalParameter>(this.FormalParameters, value.FormalParameters) || !Utilities.IsListEqual <InputSet>(this.InputSets, value.InputSets) || !Utilities.IsListEqual <OutputSet>(this.OutputSets, value.OutputSets) || !Utilities.IsListEqual <Participant>(this.Participants, value.Participants) || !Utilities.IsListEqual <PartnerLink>(this.PartnerLinks, value.PartnerLinks) || !Utilities.IsListEqual <Transition>(this.Transitions, value.Transitions)) { return(false); } // for (int j = 0; j < listA.Count; j++) // if (listA[j] != null && listB[j] != null) // if (!listA[j].Equals(listB[j])) // return false; return(Utilities.IsEqual(listA, listB)); } return(false); }
/// <summary> /// Determines if two given lists of type "T" are equal. /// </summary> /// <typeparam name="T">Any declared type within the program.</typeparam> /// <param name="listA">The first list</param> /// <param name="listB">The second list</param> /// <returns>Returns true if both lists are completely the same or both empty. /// Returns false if number of items in the lists are not the same, /// or any single element in the list is not equal to the same element in another list.</returns> public static bool IsListEqual <T>(List <T> listA, List <T> listB) { // If both list is null means they are equal if (listA != null && listB != null) { // check number of elements in a list int count = listA.Count; // return false if list count is not equal if (listA.Count != listB.Count) { return(false); } // if both list contain nothing return true else if (listA.Count == 0 && listB.Count == 0) { return(true); } else { // recursively check each element for (int i = 0; i < count; i++) { if (listA[i] is WorkflowProcess) { WorkflowProcess w1 = listA[i] as WorkflowProcess; WorkflowProcess w2 = listB[i] as WorkflowProcess; if (!w1.Equals(w2)) { return(false); } } // return false any single pair of them is not equal else if (!listA[i].Equals(listB[i])) { return(false); } } // return true if all check can be completed return(true); } } else { return(true); } }