//************************************************************************* // Method: AddFaultToTableByName // Description: Adding Fault to hashtable by FaultName as Key // // Parameters: // newFaultToAdd - the object of type Fault Class // // Return Value: true if successful, false otherwise //************************************************************************* protected bool AddFaultToTableByName(Fault newFaultToAdd) { FaultTableByName.Add(newFaultToAdd.Name,newFaultToAdd); return true; }
//************************************************************************* // Method: ParseFault // Description: parses the xml document and extracts a fault from it // // Parameters: // childNaviator - the path navigator that represents the fault node // to extract // // Return Value: the extracted fault //************************************************************************* protected Fault ParseFault(XPathNavigator childNavigator) { XPathNavigator faultNavigator = childNavigator.Clone(); Fault fault = new Fault(); // retrive Fault tag attributes bool hasMoreAttributes = faultNavigator.MoveToFirstAttribute(); while (hasMoreAttributes) { switch(faultNavigator.Name) { case "Name": { fault.Name = faultNavigator.Value; break; } case "ReturnValue": { fault.ReturnValue = faultNavigator.Value; break; } case "ErrorCode": { fault.ErrorCode = faultNavigator.Value; break; } } hasMoreAttributes = faultNavigator.MoveToNextAttribute(); } // get back to the fault tag faultNavigator.MoveToParent(); bool hasMoreFaultElements = faultNavigator.MoveToFirstChild(); while (hasMoreFaultElements) { if (faultNavigator.Name.CompareTo("Function") == 0) { FaultFunction function = ParseFaultFunction(faultNavigator); if (function != null) fault.Function.Add(function); } hasMoreFaultElements = faultNavigator.MoveToNext(); } return fault; }
//************************************************************************* // Method: UpdateFault // Description: Updating entry of the edited Fault in FaultTableByName // // Parameters: // FaultName = name of the edited Fault here acting as Key in hashtable // EditedFault = Object of edited Fault // // Return Value: None //************************************************************************* public void UpdateFault(string FaultName, Fault EditedFault) { if(FaultTableByName.Contains(FaultName)) { FaultTableByName.Remove(FaultName); FaultTableByName.Add(EditedFault.Name,EditedFault); } else { FaultTableByName.Add(EditedFault.Name,EditedFault); } }