Esempio n. 1
0
        //*************************************************************************
        // Method:		ParseFaultFunctionMatchParams
        // Description: Extracts a fault function  Match Params from fault xml
        //
        // Parameters:
        //	childNaviator - the path navigator that represents the fault function  match param node
        //		to extract
        //
        // Return Value: the extracted FaultFunctionMatchParams function
        //*************************************************************************
        protected FaultFunctionMatchParams ParseFaultFunctionMatchParams(XPathNavigator childNavigator)
        {
            XPathNavigator           MatchParamsNavigator = childNavigator.Clone();
            FaultFunctionMatchParams MatchParams          = new FaultFunctionMatchParams();

            // retrive attribute and elements of "MatchParams" tag
            bool hasMoreMatchParamsElements = MatchParamsNavigator.MoveToFirstChild();

            while (hasMoreMatchParamsElements)
            {
                switch (MatchParamsNavigator.Name)
                {
                case "MatchParam":
                {
                    FaultFunctionMatchParams attMatchParam = ParseMatchParam(MatchParamsNavigator);
                    if (attMatchParam != null)
                    {
                        MatchParams.MatchParam.Add(attMatchParam);
                    }
                    break;
                }
                }

                hasMoreMatchParamsElements = MatchParamsNavigator.MoveToNext();
            }

            return(MatchParams);
        }
Esempio n. 2
0
        //*************************************************************************
        // Method:		ParseFaultFunctionMatchParams
        // Description: Extracts a fault function  Match Params from fault xml
        //
        // Parameters:
        //	childNaviator - the path navigator that represents the fault function  match param node
        //		to extract
        //
        // Return Value: the extracted FaultFunctionMatchParams function
        //*************************************************************************
        protected FaultFunctionMatchParams ParseFaultFunctionMatchParams(XPathNavigator childNavigator)
        {
            XPathNavigator           MatchParamsNavigator = childNavigator.Clone();
            FaultFunctionMatchParams MatchParams          = new FaultFunctionMatchParams();

            // Element "MatchPara"
            bool hasMoreMatchParamsElements = MatchParamsNavigator.MoveToFirstChild();

            while (hasMoreMatchParamsElements)
            {
                switch (MatchParamsNavigator.Name)
                {
                case "MatchParam":
                {
                    // recursivly calling "ParseFaultFunctionMatchParams" method
                    FaultFunctionMatchParams attMatchParam = ParseMatchParam(MatchParamsNavigator);
                    if (attMatchParam != null)
                    {
                        MatchParams.MatchParam.Add(attMatchParam);
                    }
                    break;
                }
                }

                hasMoreMatchParamsElements = MatchParamsNavigator.MoveToNext();
            }

            return(MatchParams);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        //*************************************************************************
        // Method:		ParseMatchParam
        // Description: Extracts a Match Param from Fault function Match Params
        //
        // Parameters:
        //	childNaviator - the path navigator that represents the fault function match params node
        //
        // Return Value: the extracted FaultFunctionMatchParams  matchParam
        //*************************************************************************
        protected FaultFunctionMatchParams ParseMatchParam(XPathNavigator childNavigator)
        {
            XPathNavigator           MatchParamNavigator = childNavigator.Clone();
            FaultFunctionMatchParams matchParam          = new FaultFunctionMatchParams();

            // get the attributes of the MatchParam tag
            bool hasMoreMatchParamAttributes = MatchParamNavigator.MoveToFirstAttribute();

            while (hasMoreMatchParamAttributes)
            {
                switch (MatchParamNavigator.Name)
                {
                case "Name":
                {
                    matchParam.Name = MatchParamNavigator.Value;
                    break;
                }

                case "TestOperator":
                {
                    matchParam.TestOperator = MatchParamNavigator.Value;
                    break;
                }

                case "TestValue":
                {
                    matchParam.TestValue = MatchParamNavigator.Value;
                    break;
                }

                case "CompareAsType":
                {
                    matchParam.CompareAsType = MatchParamNavigator.Value;
                    break;
                }

                case "ID":
                {
                    matchParam.ID = MatchParamNavigator.Value;
                    break;
                }
                }

                hasMoreMatchParamAttributes = MatchParamNavigator.MoveToNextAttribute();
            }

            return(matchParam);
        }
Esempio n. 6
0
        //*************************************************************************
        // Method:		ParseMatchParam
        // Description: Extracts a Match Param from Fault function Match Params
        //
        // Parameters:
        //    childNaviator - the path navigator that represents the fault function match params node
        //
        // Return Value: the extracted FaultFunctionMatchParams  matchParam
        //*************************************************************************
        protected FaultFunctionMatchParams ParseMatchParam(XPathNavigator childNavigator)
        {
            XPathNavigator MatchParamNavigator = childNavigator.Clone();
            FaultFunctionMatchParams matchParam = new FaultFunctionMatchParams();

            // get the attributes of the MatchParam tag
            bool hasMoreMatchParamAttributes = MatchParamNavigator.MoveToFirstAttribute();
            while(hasMoreMatchParamAttributes)
            {
                switch(MatchParamNavigator.Name)
                {
                    case "Name":
                    {
                        matchParam.Name = MatchParamNavigator.Value;
                        break;
                    }
                    case "TestOperator":
                    {
                        matchParam.TestOperator = MatchParamNavigator.Value;
                        break;
                    }
                    case "TestValue":
                    {
                        matchParam.TestValue = MatchParamNavigator.Value;
                        break;
                    }
                    case "CompareAsType":
                    {
                        matchParam.CompareAsType = MatchParamNavigator.Value;
                        break;
                    }
                    case "ID":
                    {
                        matchParam.ID = MatchParamNavigator.Value;
                        break;
                    }

                }

                hasMoreMatchParamAttributes = MatchParamNavigator.MoveToNextAttribute();
            }

            return matchParam;
        }
Esempio n. 7
0
        //*************************************************************************
        // Method:		ParseFaultFunctionMatchParams
        // Description: Extracts a fault function  Match Params from fault xml
        //
        // Parameters:
        //    childNaviator - the path navigator that represents the fault function  match param node
        //        to extract
        //
        // Return Value: the extracted FaultFunctionMatchParams function
        //*************************************************************************
        protected FaultFunctionMatchParams ParseFaultFunctionMatchParams(XPathNavigator childNavigator)
        {
            XPathNavigator MatchParamsNavigator = childNavigator.Clone();
            FaultFunctionMatchParams MatchParams = new FaultFunctionMatchParams();

            // retrive attribute and elements of "MatchParams" tag
            bool hasMoreMatchParamsElements = MatchParamsNavigator.MoveToFirstChild();
            while (hasMoreMatchParamsElements)
            {
                switch (MatchParamsNavigator.Name)
                {
                    case "MatchParam":
                    {
                        FaultFunctionMatchParams attMatchParam = ParseMatchParam(MatchParamsNavigator);
                        if (attMatchParam != null)
                            MatchParams.MatchParam.Add(attMatchParam);
                        break;

                    }
                }

                hasMoreMatchParamsElements = MatchParamsNavigator.MoveToNext();
            }

            return MatchParams;
        }
Esempio n. 8
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);
        }