Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Test Appliacation to test faults.xml");
            try
            {
                FaultXMLNavigator FaultXMLNav = new FaultXMLNavigator();
                //string FaultXMLFilePath = @"E:\Fall2003\Holodeck xml files\faults.xml";
                string FaultXMLFilePath = @"E:\Fall2003\Holodeck xml files\holo 2.5\faultsnew.xml";
                FaultXMLNav.ValidateXmlDocument(FaultXMLFilePath);
                FaultXMLNav.parseXmlDocument(FaultXMLFilePath);

                //modify fault
                Fault modifyThisFault = FaultXMLNav.GetFaultByName("PagingFileTooSmall");

                if(modifyThisFault != null)
                {
                    modifyThisFault.ReturnValue = "test_0";
                    modifyThisFault.ErrorCode = "Test_1454";

                    FaultFunction function = new FaultFunction();
                    function.Name = "GlobalReAlloc";
                    function.Allocation = "test_GT";
                    function.PassThrough = "TEST_not_there";

                    FaultFunctionMatchParams matchparams = new FaultFunctionMatchParams();

                    FaultFunctionMatchParams matchparam = new FaultFunctionMatchParams();
                    matchparam.Name= "Flags";
                    matchparam.TestOperator = "test_not contains";
                    matchparam.TestValue = "Test_128";
                    matchparam.CompareAsType = "test_4";
                    matchparam.ID = "test_2";

                    matchparams.MatchParam.Insert(0,matchparam);

                    function.MatchParams.Insert(0,matchparams);

                    modifyThisFault.Function[0] = function;

                    FaultXMLNav.UpdateFault("PagingFileTooSmall",modifyThisFault);

                }

                FaultXMLNav.saveFaultXmlDocument(FaultXMLNav,"fault-save.xml","",true);
            }

            catch(FileNotFoundException f)
            {
                Console.WriteLine(" File Not Found Exception caught.... : " + f.Message);
                Console.WriteLine("Details: " + f.StackTrace);
            }
            catch(SystemException e)
            {
                Console.WriteLine("Caught  System Exception .... : " + e.Message);
                Console.WriteLine("Details: " + e.StackTrace);
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Test Appliacation to test faults.xml");
            try
            {
                FaultXMLNavigator FaultXMLNav = new FaultXMLNavigator();
                //string FaultXMLFilePath = @"E:\Fall2003\Holodeck xml files\faults.xml";
                string FaultXMLFilePath = @"E:\Fall2003\Holodeck xml files\holo 2.5\faultsnew.xml";
                FaultXMLNav.ValidateXmlDocument(FaultXMLFilePath);
                FaultXMLNav.parseXmlDocument(FaultXMLFilePath);

                //modify fault
                Fault modifyThisFault = FaultXMLNav.GetFaultByName("PagingFileTooSmall");

                if (modifyThisFault != null)
                {
                    modifyThisFault.ReturnValue = "test_0";
                    modifyThisFault.ErrorCode   = "Test_1454";

                    FaultFunction function = new FaultFunction();
                    function.Name        = "GlobalReAlloc";
                    function.Allocation  = "test_GT";
                    function.PassThrough = "TEST_not_there";

                    FaultFunctionMatchParams matchparams = new FaultFunctionMatchParams();

                    FaultFunctionMatchParams matchparam = new FaultFunctionMatchParams();
                    matchparam.Name          = "Flags";
                    matchparam.TestOperator  = "test_not contains";
                    matchparam.TestValue     = "Test_128";
                    matchparam.CompareAsType = "test_4";
                    matchparam.ID            = "test_2";

                    matchparams.MatchParam.Insert(0, matchparam);

                    function.MatchParams.Insert(0, matchparams);

                    modifyThisFault.Function[0] = function;

                    FaultXMLNav.UpdateFault("PagingFileTooSmall", modifyThisFault);
                }

                FaultXMLNav.saveFaultXmlDocument(FaultXMLNav, "fault-save.xml", "", true);
            }

            catch (FileNotFoundException f)
            {
                Console.WriteLine(" File Not Found Exception caught.... : " + f.Message);
                Console.WriteLine("Details: " + f.StackTrace);
            }
            catch (SystemException e)
            {
                Console.WriteLine("Caught  System Exception .... : " + e.Message);
                Console.WriteLine("Details: " + e.StackTrace);
            }
        }
Ejemplo n.º 3
0
        //*************************************************************************
        // 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);
        }
Ejemplo n.º 4
0
        //*************************************************************************
        // Method:		ParseFaultFunction
        // Description: parses the xml document and extracts a fault function from it
        //
        // Parameters:
        //	childNaviator - the path navigator that represents the fault function node
        //		to extract
        //
        // Return Value: the extracted fault function
        //*************************************************************************
        protected FaultFunction ParseFaultFunction(XPathNavigator childNavigator)
        {
            XPathNavigator functionNavigator = childNavigator.Clone();
            FaultFunction  function          = new FaultFunction();

            function.Name = functionNavigator.Value;

            // get the attributes of the function tag
            bool hasMoreAttributes = functionNavigator.MoveToFirstAttribute();

            while (hasMoreAttributes)
            {
                switch (functionNavigator.Name)
                {
                case "Name":
                {
                    function.Name = functionNavigator.Value;
                    break;
                }

                case "OverrideErrorCode":
                {
                    function.OverrideErrorCode = functionNavigator.Value;
                    break;
                }

                case "OverrideReturnValue":
                {
                    function.OverrideReturnValue = functionNavigator.Value;
                    break;
                }

                case "PassThrough":
                {
                    function.PassThrough = functionNavigator.Value;
                    break;
                }

                case "Exception":
                {
                    function.Exception = functionNavigator.Value;
                    break;
                }

                case "Allocation":
                {
                    function.Allocation = functionNavigator.Value;
                    break;
                }
                }

                hasMoreAttributes = functionNavigator.MoveToNextAttribute();
            }

            // get back to the function tag
            functionNavigator.MoveToParent();

            bool hasMoreFunctionElements = functionNavigator.MoveToFirstChild();

            while (hasMoreFunctionElements)
            {
                switch (functionNavigator.Name)
                {
                case "MatchParams":
                {
                    FaultFunctionMatchParams FunctionMatchParams = ParseFaultFunctionMatchParams(functionNavigator);
                    if (FunctionMatchParams != null)
                    {
                        function.MatchParams.Add(FunctionMatchParams);
                    }
                    break;
                }

                case "CheckResource":
                {
                    FaultFunctionCheckResource FunctionCheckResource = ParseFaultFunctionCheckResource(functionNavigator);
                    if (FunctionCheckResource != null)
                    {
                        function.CheckResource.Add(FunctionCheckResource);
                    }
                    break;
                }
                }

                hasMoreFunctionElements = functionNavigator.MoveToNext();
            }

            functionNavigator.MoveToParent();

            return(function);
        }
Ejemplo n.º 5
0
        //*************************************************************************
        // Method:		ParseFaultFunction
        // Description: parses the xml document and extracts a fault function from it
        //
        // Parameters:
        //    childNaviator - the path navigator that represents the fault function node
        //        to extract
        //
        // Return Value: the extracted fault function
        //*************************************************************************
        protected FaultFunction ParseFaultFunction(XPathNavigator childNavigator)
        {
            XPathNavigator functionNavigator = childNavigator.Clone();
            FaultFunction function = new FaultFunction();

            function.Name = functionNavigator.Value;

            // get the attributes of the function tag
            bool hasMoreAttributes = functionNavigator.MoveToFirstAttribute();
            while (hasMoreAttributes)
            {
                switch(functionNavigator.Name)
                {
                    case "Name":
                    {
                        function.Name = functionNavigator.Value;
                        break;
                    }
                    case "OverrideErrorCode":
                    {
                        function.OverrideErrorCode = functionNavigator.Value;
                        break;
                    }
                    case "OverrideReturnValue":
                    {
                        function.OverrideReturnValue = functionNavigator.Value;
                        break;
                    }
                    case "PassThrough":
                    {
                        function.PassThrough = functionNavigator.Value;
                        break;
                    }
                    case "Exception":
                    {
                        function.Exception = functionNavigator.Value;
                        break;
                    }
                    case "Allocation":
                    {
                        function.Allocation = functionNavigator.Value;
                        break;
                    }
                }

                hasMoreAttributes = functionNavigator.MoveToNextAttribute();
            }

            // get back to the function tag
            functionNavigator.MoveToParent();

            bool hasMoreFunctionElements = functionNavigator.MoveToFirstChild();
            while (hasMoreFunctionElements)
            {
                switch (functionNavigator.Name)
                {
                    case "MatchParams":
                    {
                        FaultFunctionMatchParams FunctionMatchParams = ParseFaultFunctionMatchParams(functionNavigator);
                        if (FunctionMatchParams != null)
                            function.MatchParams.Add(FunctionMatchParams);
                        break;

                    }
                    case "CheckResource":
                    {
                        FaultFunctionCheckResource FunctionCheckResource = ParseFaultFunctionCheckResource(functionNavigator);
                        if (FunctionCheckResource != null)
                            function.CheckResource.Add(FunctionCheckResource);
                        break;
                    }
                }

                hasMoreFunctionElements = functionNavigator.MoveToNext();
            }

            functionNavigator.MoveToParent();

            return function;
        }