Пример #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Test Appliacation to test Function.xml");
            FunctionXMLNavigator FuncXMLNav = new FunctionXMLNavigator();
            string FunctionXMLFilePath = @"E:\Fall2003\Holodeck xml files\functions.xml";
            FuncXMLNav.parseXmlDocument(FunctionXMLFilePath);

            //modifying function here
            Function modifyThis = FuncXMLNav.GetFunctionByName( "bind" );
            modifyThis.OriginalDll = "TESTws2_32.dll";
            modifyThis.InterceptedDll = "TESTws2_32replacementlibrary.dll";
            modifyThis.ReplacementFunctionName = "TESTbindReplacement";
            modifyThis.ReturnType = "TESTint";
            modifyThis.Modifiers[0] = "TESTWINSOCK_API_LINKAGE";
            modifyThis.Modifiers[1] = "TESTWSAAPI";
            modifyThis.Category = "TESTNETWORK";
            modifyThis.ReturnValueDescription = "TESTOn success returns zero. On failure returns SOCKET_ERROR (-1).";

            Parameter modifiedParam = new Parameter();
            modifiedParam.Name ="TESTs" ;
            modifiedParam.Index = 01;
            modifiedParam.Type ="TESTSOCKET" ;
            modifiedParam.CompareAs ="TESTPointerType" ;
            modifiedParam.Access ="TESTIN" ;
            modifyThis.Parameter[0] = modifiedParam;

            Parameter modifiedParam1 = new Parameter();
            modifiedParam1.Name ="TESTname" ;
            modifiedParam1.Index = 11;
            modifiedParam1.Type ="TESTconst struct sockaddr FAR *" ;
            modifiedParam1.CompareAs ="TESTPointerType" ;
            modifiedParam1.Access ="TESTIN" ;
            modifyThis.Parameter[1] = modifiedParam1;

            Parameter modifiedParam2 = new Parameter();
            modifiedParam2.Name = "TESTnamelen" ;
            modifiedParam2.Index = 22;
            modifiedParam2.Type ="TESTint" ;
            modifiedParam2.CompareAs ="TESTIntegerType" ;
            modifiedParam2.Access ="TESTIN" ;
            modifyThis.Parameter[2] = modifiedParam2;

            FuncXMLNav.UpdateFunctionByName("bind",modifyThis);

            //saving the function.xml
            FuncXMLNav.saveFunctionXmlDocument(FuncXMLNav,"functions.xml");

            // DotNetFunctions.xml
            Console.WriteLine("This is Test Appliacation to test DotNetFunctions.xml");
            FunctionXMLNavigator DotNetFuncXMLNav = new FunctionXMLNavigator();
            string DotNetFunctionXMLFilePath = @"E:\Fall2003\Holodeck xml files\DotNetFunctions.xml";
            DotNetFuncXMLNav.parseXmlDocument(DotNetFunctionXMLFilePath);
            DotNetFuncXMLNav.saveFunctionXmlDocument(DotNetFuncXMLNav,"DotNetFunctions.xml");
        }
Пример #2
0
        ///*************************************************************************
        /// Method:		saveFunctionXmlDocument
        /// Description: recreating functions.xml document 
        ///
        /// Parameters:
        ///	functionXMLNavigator :
        ///
        ///	fileNameToSaveAs : filename
        ///
        ///  Return Value:  None
        ///*************************************************************************
        public void saveFunctionXmlDocument(FunctionXMLNavigator functionXMLNavigator, string fileNameToSaveAs,string fileEncoding,bool isValidationRequired)
        {
            XmlTextWriter saveFunctionXml;

            switch(fileEncoding.ToUpper())
            {
                case "UTF-8":
                case "":
                {
                    saveFunctionXml = new XmlTextWriter(fileNameToSaveAs,System.Text.UTF8Encoding.UTF8);
                    saveFunctionXml.Formatting = Formatting.Indented;
                    saveFunctionXml.WriteRaw( "<?xml version= \"1.0\"?>" );
                    break;
                }
                case "UTF-7":
                {
                    saveFunctionXml = new XmlTextWriter(fileNameToSaveAs,System.Text.UTF7Encoding.UTF7);
                    saveFunctionXml.Formatting = Formatting.Indented;
                    saveFunctionXml.WriteRaw( "<?xml version= \"1.0\" encoding=\"UTF-7\"?>" );
                    break;
                }
                case "ASCII":
                {
                    saveFunctionXml = new XmlTextWriter(fileNameToSaveAs,System.Text.ASCIIEncoding.ASCII);
                    saveFunctionXml.Formatting = Formatting.Indented;
                    saveFunctionXml.WriteRaw( "<?xml version= \"1.0\" encoding=\"ASCII\"?>" );
                    break;
                }
                case "Unicode":
                {
                    saveFunctionXml = new XmlTextWriter(fileNameToSaveAs,System.Text.UnicodeEncoding.Unicode);
                    saveFunctionXml.Formatting = Formatting.Indented;
                    saveFunctionXml.WriteRaw( "<?xml version= \"1.0\" encoding=\"Unicode\"?>" );
                    break;
                }
                default:
                {
                    saveFunctionXml = new XmlTextWriter(fileNameToSaveAs,null);
                    saveFunctionXml.Formatting = Formatting.Indented;
                    saveFunctionXml.WriteRaw( "<?xml version= \"1.0\"?>" );
                    break;
                }

            }

            if(isValidationRequired)
            {
                saveFunctionXml.WriteDocType("Functions",null,"functions.dtd","");
            }

            saveFunctionXml.WriteStartElement("Functions");

            foreach(string FunctionNameAsKey in FunctionTableByName.Keys)
            {
                Function FunctionToSave = functionXMLNavigator.GetFunctionByName(FunctionNameAsKey);

                ///Element = Function
                saveFunctionXml.WriteStartElement("Function");

                //Element = FunctionName
                saveFunctionXml.WriteStartElement("FunctionName");
                saveFunctionXml.WriteString(FunctionToSave.FunctionName.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = OriginalDll
                saveFunctionXml.WriteStartElement("OriginalDll");
                saveFunctionXml.WriteString(FunctionToSave.OriginalDll.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = InterceptedDll
                saveFunctionXml.WriteStartElement("InterceptedDll");
                saveFunctionXml.WriteString(FunctionToSave.InterceptedDll.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = ReplacementFunctionName
                saveFunctionXml.WriteStartElement("ReplacementFunctionName");
                saveFunctionXml.WriteString(FunctionToSave.ReplacementFunctionName.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = ReturnType
                saveFunctionXml.WriteStartElement("ReturnType");
                saveFunctionXml.WriteString(FunctionToSave.ReturnType.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = Modifier
                for(int indexModifier =0; indexModifier < FunctionToSave.Modifiers.Count;indexModifier ++)
                {
                    saveFunctionXml.WriteStartElement("TypeModifier");
                    saveFunctionXml.WriteString(FunctionToSave.Modifiers[indexModifier].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                //Element = CallingConventionModifier
                for(int indexCallingConventionModifier =0; indexCallingConventionModifier < FunctionToSave.CallingConventionModifier.Count;indexCallingConventionModifier ++)
                {
                    saveFunctionXml.WriteStartElement("CallingConventionModifier");
                    saveFunctionXml.WriteString(FunctionToSave.CallingConventionModifier[indexCallingConventionModifier].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                //Element = Category
                saveFunctionXml.WriteStartElement("Category");
                saveFunctionXml.WriteString(FunctionToSave.Category.ToString());
                saveFunctionXml.WriteFullEndElement();

                ///Element = ReturnValue
                foreach(ReturnValue returnValue in FunctionToSave.ReturnValue)
                {
                    ///Element = ReturnValue
                    saveFunctionXml.WriteStartElement("ReturnValue");

                    ///Attribute = Type
                    if(returnValue.Type != null)
                    {
                        saveFunctionXml.WriteAttributeString("Type",returnValue.Type.ToString());
                    }

                    ///Attribute = ValueOperator
                    if(returnValue.ValueOperator != null)
                    {
                        saveFunctionXml.WriteAttributeString("ValueOperator",returnValue.ValueOperator.ToString());
                    }

                    saveFunctionXml.WriteString(returnValue.NodeValue.ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                ///Element = Exception
                for(int indexException =0; indexException < FunctionToSave.Exception.Count;indexException ++)
                {
                    saveFunctionXml.WriteStartElement("Exception");
                    saveFunctionXml.WriteString(FunctionToSave.Exception[indexException].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                /// Element = HelpLink
                saveFunctionXml.WriteStartElement("HelpLink");
                saveFunctionXml.WriteString(FunctionToSave.HelpLink.ToString());
                saveFunctionXml.WriteFullEndElement();

                /// Element = Param
                foreach(Parameter param in FunctionToSave.Parameter)
                {
                    ///Element = Param
                    saveFunctionXml.WriteStartElement("Param");

                    ///Attribute = Index
                    if(param.Index != -1)
                    {
                        saveFunctionXml.WriteAttributeString("Index",param.Index.ToString());
                    }

                    ///Attribute = Type
                    if(param.Type != null)
                    {
                        saveFunctionXml.WriteAttributeString("Type",param.Type.ToString());
                    }

                    ///Attribute = CompareAs
                    if(param.CompareAs != null)
                    {
                        saveFunctionXml.WriteAttributeString("CompareAs",param.CompareAs.ToString());
                    }

                    ///Attribute = Access
                    if(param.Access != null)
                    {
                        saveFunctionXml.WriteAttributeString("Access",param.Access.ToString());
                    }

                    ///Attribute = PointsToResource
                    if(param.PointsToResource != null)
                    {
                        saveFunctionXml.WriteAttributeString("PointsToResource",param.PointsToResource.ToString());
                    }

                    ///Attribute = ConcatWith
                    if(param.ConcatWith != null)
                    {
                        saveFunctionXml.WriteAttributeString("ConcatWith",param.ConcatWith.ToString());
                    }

                    ///Attribute = MapTo
                    if(param.MapTo != null)
                    {
                        saveFunctionXml.WriteAttributeString("MapTo",param.MapTo.ToString());
                    }

                    saveFunctionXml.WriteString(param.Name.ToString());
                    saveFunctionXml.WriteFullEndElement();

                }

                ///Element = ErrorCode
                foreach(ErrorCode errorCode in FunctionToSave.ErrorCode)
                {
                    ///Element = ErrorCode
                    saveFunctionXml.WriteStartElement("ErrorCode");

                    ///Attribute = IdentifyBy
                    if(errorCode.IdentifiedBy != null)
                    {
                        saveFunctionXml.WriteAttributeString("IdentifyBy",errorCode.IdentifiedBy.ToString());
                    }

                    ///Attribute = Type
                    if(errorCode.Type != null)
                    {
                        saveFunctionXml.WriteAttributeString("Type",errorCode.Type.ToString());
                    }

                    saveFunctionXml.WriteString(errorCode.NodeValue.ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                saveFunctionXml.WriteFullEndElement();

            }
            saveFunctionXml.WriteFullEndElement();

            //closing xmlwriter.
            saveFunctionXml.Close();
        }
Пример #3
0
        public void saveFunctionXmlDocument(FunctionXMLNavigator functionXMLNavigator)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlDeclaration xmlDecl;

            xmlDecl = xmlDoc.CreateXmlDeclaration("1.0", null, null);
//			xmlDecl.Encoding="UTF-8";
//			xmlDecl.Standalone="yes";
            XmlNode docTypeNode = xmlDoc.CreateNode(XmlNodeType.DocumentType, "Functions", "functions.dtd");


            XmlElement rootElement = xmlDoc.CreateElement("Functions");

            xmlDoc.AppendChild(rootElement);
            xmlDoc.InsertBefore(xmlDecl, rootElement);
            xmlDoc.InsertBefore(docTypeNode, rootElement);

            foreach (string FunctionNameAsKey in FunctionTableByName.Keys)
            {
                Function FunctionToSave = functionXMLNavigator.GetFunctionByName(FunctionNameAsKey);

                ///Element = Function
                XmlElement FuncElement = xmlDoc.CreateElement("Function");
                rootElement.AppendChild(FuncElement);

                ///Element = FunctionName
                XmlElement elmFunctionName = xmlDoc.CreateElement("FunctionName");
                elmFunctionName.InnerText = FunctionToSave.FunctionName;
                FuncElement.AppendChild(elmFunctionName);

                ///Element = OriginalDll
                XmlElement elmOriginalDll = xmlDoc.CreateElement("OriginalDll");
                elmOriginalDll.InnerText = FunctionToSave.OriginalDll;
                FuncElement.AppendChild(elmOriginalDll);


                ///Element = InterceptedDll
                XmlElement elmInterceptedDll = xmlDoc.CreateElement("InterceptedDll");
                elmInterceptedDll.InnerText = FunctionToSave.InterceptedDll;
                FuncElement.AppendChild(elmInterceptedDll);

                ///Element = ReplacementFunctionName
                XmlElement elmReplacementFunctionName = xmlDoc.CreateElement("ReplacementFunctionName");
                elmReplacementFunctionName.InnerText = FunctionToSave.ReplacementFunctionName;
                FuncElement.AppendChild(elmReplacementFunctionName);

                ///Element = ReturnType
                XmlElement elmReturnType = xmlDoc.CreateElement("ReturnType");
                elmReturnType.InnerText = FunctionToSave.ReturnType;
                FuncElement.AppendChild(elmReturnType);


                ///Element = Modifier
                for (int indexModifier = 0; indexModifier < FunctionToSave.Modifiers.Count; indexModifier++)
                {
                    XmlElement elmModifier = xmlDoc.CreateElement("Modifier");
                    elmModifier.InnerText = FunctionToSave.Modifiers[indexModifier].ToString();
                    FuncElement.AppendChild(elmModifier);
                }

                ///Element = Category
                XmlElement elmCategory = xmlDoc.CreateElement("Category");
                elmCategory.InnerText = FunctionToSave.Category;
                FuncElement.AppendChild(elmCategory);

                ///Element = ReturnValueDescription
                XmlElement elmReturnValueDescription = xmlDoc.CreateElement("ReturnValueDescription");
                elmReturnValueDescription.InnerText = FunctionToSave.ReturnValueDescription;
                FuncElement.AppendChild(elmReturnValueDescription);

                // Element = Param
                foreach (Parameter param in FunctionToSave.Parameter)
                {
                    ///Element = Param
                    XmlElement elmParam = xmlDoc.CreateElement("Param");
                    elmParam.InnerText = param.Name;
                    FuncElement.AppendChild(elmParam);

                    //Attribute = Index
                    XmlAttribute attrIndex = xmlDoc.CreateAttribute("Index");
                    attrIndex.Value = param.Index.ToString();
                    elmParam.Attributes.Append(attrIndex);

                    //Attribute = Type
                    XmlAttribute attrType = xmlDoc.CreateAttribute("Type");
                    attrType.Value = param.Type;
                    elmParam.Attributes.Append(attrType);

                    //Attribute = CompareAs
                    XmlAttribute attrCompareAs = xmlDoc.CreateAttribute("CompareAs");
                    attrCompareAs.Value = param.CompareAs;
                    elmParam.Attributes.Append(attrCompareAs);

                    //Attribute = Access
                    XmlAttribute attrAccess = xmlDoc.CreateAttribute("Access");
                    attrAccess.Value = param.Access;
                    elmParam.Attributes.Append(attrAccess);
                }

                //Element = ErrorCode
                foreach (ErrorCode errorCode in FunctionToSave.ErrorCode)
                {
                    ///Element = ErrorCode
                    XmlElement elmErrorCode = xmlDoc.CreateElement("ErrorCode");
                    elmErrorCode.InnerText = errorCode.NodeValue;
                    FuncElement.AppendChild(elmErrorCode);

                    //Attribute = IdentifyBy
                    XmlAttribute attrIdentifyBy = xmlDoc.CreateAttribute("IdentifyBy");
                    attrIdentifyBy.Value = errorCode.IdentifiedBy;
                    elmErrorCode.Attributes.Append(attrIdentifyBy);
                }
            }

            //Saving Xml doc
            xmlDoc.Save("functions.xml");
        }
Пример #4
0
        public void saveFunctionXmlDocument(FunctionXMLNavigator functionXMLNavigator)
        {
            XmlDocument xmlDoc = new XmlDocument();

            XmlDeclaration xmlDecl;
            xmlDecl = xmlDoc.CreateXmlDeclaration("1.0",null,null);
            //			xmlDecl.Encoding="UTF-8";
            //			xmlDecl.Standalone="yes";
            XmlNode docTypeNode = xmlDoc.CreateNode( XmlNodeType.DocumentType, "Functions","functions.dtd" );

            XmlElement rootElement = xmlDoc.CreateElement("Functions");

            xmlDoc.AppendChild(rootElement);
            xmlDoc.InsertBefore(xmlDecl,rootElement);
            xmlDoc.InsertBefore(docTypeNode,rootElement);

            foreach(string FunctionNameAsKey in FunctionTableByName.Keys)
            {
                Function FunctionToSave = functionXMLNavigator.GetFunctionByName(FunctionNameAsKey);

                ///Element = Function
                XmlElement FuncElement = xmlDoc.CreateElement("Function");
                rootElement.AppendChild (FuncElement);

                ///Element = FunctionName
                XmlElement elmFunctionName = xmlDoc.CreateElement("FunctionName");
                elmFunctionName.InnerText= FunctionToSave.FunctionName;
                FuncElement.AppendChild (elmFunctionName);

                ///Element = OriginalDll
                XmlElement elmOriginalDll = xmlDoc.CreateElement("OriginalDll");
                elmOriginalDll.InnerText= FunctionToSave.OriginalDll;
                FuncElement.AppendChild (elmOriginalDll);

                ///Element = InterceptedDll
                XmlElement elmInterceptedDll = xmlDoc.CreateElement("InterceptedDll");
                elmInterceptedDll.InnerText= FunctionToSave.InterceptedDll;
                FuncElement.AppendChild (elmInterceptedDll);

                ///Element = ReplacementFunctionName
                XmlElement elmReplacementFunctionName = xmlDoc.CreateElement("ReplacementFunctionName");
                elmReplacementFunctionName.InnerText= FunctionToSave.ReplacementFunctionName;
                FuncElement.AppendChild (elmReplacementFunctionName);

                ///Element = ReturnType
                XmlElement elmReturnType = xmlDoc.CreateElement("ReturnType");
                elmReturnType.InnerText= FunctionToSave.ReturnType;
                FuncElement.AppendChild (elmReturnType);

                ///Element = Modifier
                for(int indexModifier =0; indexModifier < FunctionToSave.Modifiers.Count;indexModifier ++)
                {
                    XmlElement elmModifier = xmlDoc.CreateElement("Modifier");
                    elmModifier.InnerText = FunctionToSave.Modifiers[indexModifier].ToString();
                    FuncElement.AppendChild (elmModifier);
                }

                ///Element = Category
                XmlElement elmCategory = xmlDoc.CreateElement("Category");
                elmCategory.InnerText= FunctionToSave.Category;
                FuncElement.AppendChild (elmCategory);

                ///Element = ReturnValueDescription
                XmlElement elmReturnValueDescription = xmlDoc.CreateElement("ReturnValueDescription");
                elmReturnValueDescription.InnerText= FunctionToSave.ReturnValueDescription;
                FuncElement.AppendChild (elmReturnValueDescription);

                // Element = Param
                foreach(Parameter param in FunctionToSave.Parameter)
                {
                    ///Element = Param
                    XmlElement elmParam  = xmlDoc.CreateElement("Param");
                    elmParam.InnerText = param.Name;
                    FuncElement.AppendChild (elmParam);

                    //Attribute = Index
                    XmlAttribute attrIndex = xmlDoc.CreateAttribute("Index");
                    attrIndex.Value = param.Index.ToString();
                    elmParam.Attributes.Append (attrIndex);

                    //Attribute = Type
                    XmlAttribute attrType = xmlDoc.CreateAttribute("Type");
                    attrType.Value = param.Type;
                    elmParam.Attributes.Append (attrType);

                    //Attribute = CompareAs
                    XmlAttribute attrCompareAs = xmlDoc.CreateAttribute("CompareAs");
                    attrCompareAs.Value = param.CompareAs;
                    elmParam.Attributes.Append (attrCompareAs);

                    //Attribute = Access
                    XmlAttribute attrAccess = xmlDoc.CreateAttribute("Access");
                    attrAccess.Value = param.Access;
                    elmParam.Attributes.Append (attrAccess);

                }

                //Element = ErrorCode
                foreach(ErrorCode errorCode in FunctionToSave.ErrorCode)
                {
                    ///Element = ErrorCode
                    XmlElement elmErrorCode  = xmlDoc.CreateElement("ErrorCode");
                    elmErrorCode.InnerText = errorCode.NodeValue;
                    FuncElement.AppendChild (elmErrorCode);

                    //Attribute = IdentifyBy
                    XmlAttribute attrIdentifyBy = xmlDoc.CreateAttribute("IdentifyBy");
                    attrIdentifyBy.Value = errorCode.IdentifiedBy;
                    elmErrorCode.Attributes.Append (attrIdentifyBy);
                }

            }

            //Saving Xml doc
            xmlDoc.Save("functions.xml");
        }
Пример #5
0
        //*************************************************************************
        // Method:		saveFunctionXmlDocument
        // Description: recreating functions.xml document
        //
        // Parameters:
        //	functionXMLNavigator
        //
        //  Return Value:  None
        //*************************************************************************
        public void saveFunctionXmlDocument(FunctionXMLNavigator functionXMLNavigator, string fileNameToSaveAs)
        {
            XmlTextWriter saveFunctionXml = new XmlTextWriter(fileNameToSaveAs, null);

            saveFunctionXml.Formatting = Formatting.Indented;

            saveFunctionXml.WriteRaw("<?xml version= \"1.0\"?>");

            saveFunctionXml.WriteDocType("Functions", null, "functions.dtd", "");

            saveFunctionXml.WriteStartElement("Functions");


            foreach (string FunctionNameAsKey in FunctionTableByName.Keys)
            {
                Function FunctionToSave = functionXMLNavigator.GetFunctionByName(FunctionNameAsKey);

                ///Element = Function
                saveFunctionXml.WriteStartElement("Function");


                //Element = FunctionName
                saveFunctionXml.WriteStartElement("FunctionName");
                saveFunctionXml.WriteString(FunctionToSave.FunctionName);
                saveFunctionXml.WriteFullEndElement();

                //Element = OriginalDll
                saveFunctionXml.WriteStartElement("OriginalDll");
                saveFunctionXml.WriteString(FunctionToSave.OriginalDll);
                saveFunctionXml.WriteFullEndElement();

                ///Element = InterceptedDll
                saveFunctionXml.WriteStartElement("InterceptedDll");
                saveFunctionXml.WriteString(FunctionToSave.InterceptedDll);
                saveFunctionXml.WriteFullEndElement();

                ///Element = ReplacementFunctionName
                saveFunctionXml.WriteStartElement("ReplacementFunctionName");
                saveFunctionXml.WriteString(FunctionToSave.ReplacementFunctionName);
                saveFunctionXml.WriteFullEndElement();

                ///Element = ReturnType
                saveFunctionXml.WriteStartElement("ReturnType");
                saveFunctionXml.WriteString(FunctionToSave.ReturnType);
                saveFunctionXml.WriteFullEndElement();

                ///Element = Modifier
                for (int indexModifier = 0; indexModifier < FunctionToSave.Modifiers.Count; indexModifier++)
                {
                    saveFunctionXml.WriteStartElement("Modifier");
                    saveFunctionXml.WriteString(FunctionToSave.Modifiers[indexModifier].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                ///Element = Category
                saveFunctionXml.WriteStartElement("Category");
                saveFunctionXml.WriteString(FunctionToSave.Category);
                saveFunctionXml.WriteFullEndElement();

                ///Element = ReturnValueDescription
                saveFunctionXml.WriteStartElement("ReturnValueDescription");
                saveFunctionXml.WriteString(FunctionToSave.ReturnValueDescription);
                saveFunctionXml.WriteFullEndElement();

                ///Element = Exception
                for (int indexException = 0; indexException < FunctionToSave.Exception.Count; indexException++)
                {
                    saveFunctionXml.WriteStartElement("Exception");
                    saveFunctionXml.WriteString(FunctionToSave.Exception[indexException].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                /// Element = Param
                foreach (Parameter param in FunctionToSave.Parameter)
                {
                    ///Element = Param
                    saveFunctionXml.WriteStartElement("Param");

                    ///Attribute = Index
                    saveFunctionXml.WriteAttributeString("Index", param.Index.ToString());

                    ///Attribute = Type
                    saveFunctionXml.WriteAttributeString("Type", param.Type);


                    ///Attribute = CompareAs
                    saveFunctionXml.WriteAttributeString("CompareAs", param.CompareAs);


                    ///Attribute = Access
                    saveFunctionXml.WriteAttributeString("Access", param.Access);

                    saveFunctionXml.WriteString(param.Name);
                    saveFunctionXml.WriteFullEndElement();
                }

                ///Element = ErrorCode
                foreach (ErrorCode errorCode in FunctionToSave.ErrorCode)
                {
                    ///Element = ErrorCode
                    saveFunctionXml.WriteStartElement("ErrorCode");

                    ///Attribute = IdentifyBy
                    saveFunctionXml.WriteAttributeString("IdentifyBy", errorCode.IdentifiedBy);

                    saveFunctionXml.WriteString(errorCode.NodeValue);
                    saveFunctionXml.WriteFullEndElement();
                }

                saveFunctionXml.WriteFullEndElement();
            }
            saveFunctionXml.WriteFullEndElement();
        }
Пример #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Test Appliacation to test Functions.xml");
            try
            {
                FunctionXMLNavigator FuncXMLNav = new FunctionXMLNavigator();


                //enter the "Function.xml" path
                string FunctionXMLFilePath = @"E:\Fall2003\Holodeck xml files\holo 2.5\functions.xml";
                FuncXMLNav.ValidateXmlDocument(FunctionXMLFilePath);
                FuncXMLNav.parseXmlDocument(FunctionXMLFilePath);

                //modifying function here
                Function modifyThis = FuncXMLNav.GetFunctionByName("bind");

                //if function not found in original finctions.xml file then it we cannot modify it
                // nor we can add new function to the file
                if (modifyThis != null)
                {
                    modifyThis.OriginalDll             = "TESTws2_32.dll";
                    modifyThis.InterceptedDll          = "TESTws2_32replacementlibrary.dll";
                    modifyThis.ReplacementFunctionName = "TESTbindReplacement";
                    modifyThis.ReturnType   = "TESTint";
                    modifyThis.Modifiers[0] = "TESTWINSOCK_API_LINKAGE";
                    modifyThis.Modifiers[1] = "TESTWSAAPI";
                    modifyThis.Category     = "TESTNETWORK";

                    ReturnValue modifiedReturnValue_0 = new ReturnValue();
                    modifiedReturnValue_0.NodeValue = "TEST_0";
                    modifiedReturnValue_0.Type      = "TEST_Success";
                    modifyThis.ReturnValue[0]       = modifiedReturnValue_0;

                    ReturnValue modifiedReturnValue_1 = new ReturnValue();
                    modifiedReturnValue_1.NodeValue = "TEST_-1(SOCKET_ERROR)";
                    modifiedReturnValue_0.Type      = "TEST_Error";
                    modifyThis.ReturnValue[1]       = modifiedReturnValue_1;

                    modifyThis.HelpLink = @"TEST_http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/bind_2.asp";

                    Parameter modifiedParam = new Parameter();
                    modifiedParam.Name      = "TESTs";
                    modifiedParam.Index     = 01;
                    modifiedParam.Type      = "TESTSOCKET";
                    modifiedParam.CompareAs = "TESTPointerType";
                    modifiedParam.Access    = "TESTIN";
                    modifyThis.Parameter[0] = modifiedParam;

                    Parameter modifiedParam1 = new Parameter();
                    modifiedParam1.Name      = "TESTname";
                    modifiedParam1.Index     = 11;
                    modifiedParam1.Type      = "TESTconst struct sockaddr FAR *";
                    modifiedParam1.CompareAs = "TESTPointerType";
                    modifiedParam1.Access    = "TESTIN";
                    modifyThis.Parameter[1]  = modifiedParam1;

                    Parameter modifiedParam2 = new Parameter();
                    modifiedParam2.Name      = "TESTnamelen";
                    modifiedParam2.Index     = 22;
                    modifiedParam2.Type      = "TESTint";
                    modifiedParam2.CompareAs = "TESTIntegerType";
                    modifiedParam2.Access    = "TESTIN";
                    modifyThis.Parameter[2]  = modifiedParam2;

                    FuncXMLNav.UpdateFunctionByName("bind", modifyThis);
                }

                //saving the functions.xml
                FuncXMLNav.saveFunctionXmlDocument(FuncXMLNav, "functions.xml", "", true);

                ///cannot use DotNetFunctions.xml as new version 2.5 file is not available.
                //			// DotNetFunctions.xml
                //			Console.WriteLine("This is Test Appliacation to test DotNetFunctions.xml");
                //			FunctionXMLNavigator DotNetFuncXMLNav = new FunctionXMLNavigator();
                //			string DotNetFunctionXMLFilePath = @"E:\Fall2003\Holodeck xml files\DotNetFunctions.xml";
                //			DotNetFuncXMLNav.parseXmlDocument(DotNetFunctionXMLFilePath);
                //			DotNetFuncXMLNav.saveFunctionXmlDocument(DotNetFuncXMLNav,"DotNetFunctions.xml");
            }

            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);
            }

            EditValues test = new EditValues();
            //string vp = "abc?ejj1@3%";
            string vp = "abc__ejj1@3%";

            Console.WriteLine(vp);
            Console.WriteLine(test.ToLower(vp));
            Console.WriteLine(test.ToUpper(vp));
            Console.WriteLine(test.InsertAtStart(vp, "pppp"));
            Console.WriteLine(test.InsetAtEnd(vp, "PPPP"));
            Console.WriteLine("SplitString:" + test.SplitString(vp));
            Console.WriteLine(test.SubstituteToNull(vp));
            foreach (string sp in test.SpecialCharacters)
            {
                Console.WriteLine(sp);
            }

            Console.WriteLine(test.changeEncodingToASCII(vp));
            Console.WriteLine(test.changeEncodingToUnicode(vp));
            Console.WriteLine(test.changeEncodingToUTF7(vp));
            Console.WriteLine(test.changeEncodingToUTF8(vp));
        }
Пример #7
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Test Appliacation to test Function.xml");
            FunctionXMLNavigator FuncXMLNav = new FunctionXMLNavigator();
            string FunctionXMLFilePath      = @"E:\Fall2003\Holodeck xml files\functions.xml";

            FuncXMLNav.parseXmlDocument(FunctionXMLFilePath);

            //modifying function here
            Function modifyThis = FuncXMLNav.GetFunctionByName("bind");

            modifyThis.OriginalDll             = "TESTws2_32.dll";
            modifyThis.InterceptedDll          = "TESTws2_32replacementlibrary.dll";
            modifyThis.ReplacementFunctionName = "TESTbindReplacement";
            modifyThis.ReturnType             = "TESTint";
            modifyThis.Modifiers[0]           = "TESTWINSOCK_API_LINKAGE";
            modifyThis.Modifiers[1]           = "TESTWSAAPI";
            modifyThis.Category               = "TESTNETWORK";
            modifyThis.ReturnValueDescription = "TESTOn success returns zero. On failure returns SOCKET_ERROR (-1).";

            Parameter modifiedParam = new Parameter();

            modifiedParam.Name      = "TESTs";
            modifiedParam.Index     = 01;
            modifiedParam.Type      = "TESTSOCKET";
            modifiedParam.CompareAs = "TESTPointerType";
            modifiedParam.Access    = "TESTIN";
            modifyThis.Parameter[0] = modifiedParam;

            Parameter modifiedParam1 = new Parameter();

            modifiedParam1.Name      = "TESTname";
            modifiedParam1.Index     = 11;
            modifiedParam1.Type      = "TESTconst struct sockaddr FAR *";
            modifiedParam1.CompareAs = "TESTPointerType";
            modifiedParam1.Access    = "TESTIN";
            modifyThis.Parameter[1]  = modifiedParam1;

            Parameter modifiedParam2 = new Parameter();

            modifiedParam2.Name      = "TESTnamelen";
            modifiedParam2.Index     = 22;
            modifiedParam2.Type      = "TESTint";
            modifiedParam2.CompareAs = "TESTIntegerType";
            modifiedParam2.Access    = "TESTIN";
            modifyThis.Parameter[2]  = modifiedParam2;

            FuncXMLNav.UpdateFunctionByName("bind", modifyThis);

            //saving the function.xml
            FuncXMLNav.saveFunctionXmlDocument(FuncXMLNav, "functions.xml");


            // DotNetFunctions.xml
            Console.WriteLine("This is Test Appliacation to test DotNetFunctions.xml");
            FunctionXMLNavigator DotNetFuncXMLNav = new FunctionXMLNavigator();
            string DotNetFunctionXMLFilePath      = @"E:\Fall2003\Holodeck xml files\DotNetFunctions.xml";

            DotNetFuncXMLNav.parseXmlDocument(DotNetFunctionXMLFilePath);
            DotNetFuncXMLNav.saveFunctionXmlDocument(DotNetFuncXMLNav, "DotNetFunctions.xml");
        }
Пример #8
0
        ///*************************************************************************
        /// Method:		saveFunctionXmlDocument
        /// Description: recreating functions.xml document
        ///
        /// Parameters:
        ///	functionXMLNavigator :
        ///
        ///	fileNameToSaveAs : filename
        ///
        ///  Return Value:  None
        ///*************************************************************************
        public void saveFunctionXmlDocument(FunctionXMLNavigator functionXMLNavigator, string fileNameToSaveAs, string fileEncoding, bool isValidationRequired)
        {
            XmlTextWriter saveFunctionXml;

            switch (fileEncoding.ToUpper())
            {
            case "UTF-8":
            case "":
            {
                saveFunctionXml            = new XmlTextWriter(fileNameToSaveAs, System.Text.UTF8Encoding.UTF8);
                saveFunctionXml.Formatting = Formatting.Indented;
                saveFunctionXml.WriteRaw("<?xml version= \"1.0\"?>");
                break;
            }

            case "UTF-7":
            {
                saveFunctionXml            = new XmlTextWriter(fileNameToSaveAs, System.Text.UTF7Encoding.UTF7);
                saveFunctionXml.Formatting = Formatting.Indented;
                saveFunctionXml.WriteRaw("<?xml version= \"1.0\" encoding=\"UTF-7\"?>");
                break;
            }

            case "ASCII":
            {
                saveFunctionXml            = new XmlTextWriter(fileNameToSaveAs, System.Text.ASCIIEncoding.ASCII);
                saveFunctionXml.Formatting = Formatting.Indented;
                saveFunctionXml.WriteRaw("<?xml version= \"1.0\" encoding=\"ASCII\"?>");
                break;
            }

            case "Unicode":
            {
                saveFunctionXml            = new XmlTextWriter(fileNameToSaveAs, System.Text.UnicodeEncoding.Unicode);
                saveFunctionXml.Formatting = Formatting.Indented;
                saveFunctionXml.WriteRaw("<?xml version= \"1.0\" encoding=\"Unicode\"?>");
                break;
            }

            default:
            {
                saveFunctionXml            = new XmlTextWriter(fileNameToSaveAs, null);
                saveFunctionXml.Formatting = Formatting.Indented;
                saveFunctionXml.WriteRaw("<?xml version= \"1.0\"?>");
                break;
            }
            }

            if (isValidationRequired)
            {
                saveFunctionXml.WriteDocType("Functions", null, "functions.dtd", "");
            }

            saveFunctionXml.WriteStartElement("Functions");


            foreach (string FunctionNameAsKey in FunctionTableByName.Keys)
            {
                Function FunctionToSave = functionXMLNavigator.GetFunctionByName(FunctionNameAsKey);

                ///Element = Function
                saveFunctionXml.WriteStartElement("Function");


                //Element = FunctionName
                saveFunctionXml.WriteStartElement("FunctionName");
                saveFunctionXml.WriteString(FunctionToSave.FunctionName.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = OriginalDll
                saveFunctionXml.WriteStartElement("OriginalDll");
                saveFunctionXml.WriteString(FunctionToSave.OriginalDll.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = InterceptedDll
                saveFunctionXml.WriteStartElement("InterceptedDll");
                saveFunctionXml.WriteString(FunctionToSave.InterceptedDll.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = ReplacementFunctionName
                saveFunctionXml.WriteStartElement("ReplacementFunctionName");
                saveFunctionXml.WriteString(FunctionToSave.ReplacementFunctionName.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = ReturnType
                saveFunctionXml.WriteStartElement("ReturnType");
                saveFunctionXml.WriteString(FunctionToSave.ReturnType.ToString());
                saveFunctionXml.WriteFullEndElement();

                //Element = Modifier
                for (int indexModifier = 0; indexModifier < FunctionToSave.Modifiers.Count; indexModifier++)
                {
                    saveFunctionXml.WriteStartElement("TypeModifier");
                    saveFunctionXml.WriteString(FunctionToSave.Modifiers[indexModifier].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                //Element = CallingConventionModifier
                for (int indexCallingConventionModifier = 0; indexCallingConventionModifier < FunctionToSave.CallingConventionModifier.Count; indexCallingConventionModifier++)
                {
                    saveFunctionXml.WriteStartElement("CallingConventionModifier");
                    saveFunctionXml.WriteString(FunctionToSave.CallingConventionModifier[indexCallingConventionModifier].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                //Element = Category
                saveFunctionXml.WriteStartElement("Category");
                saveFunctionXml.WriteString(FunctionToSave.Category.ToString());
                saveFunctionXml.WriteFullEndElement();

                ///Element = ReturnValue
                foreach (ReturnValue returnValue in FunctionToSave.ReturnValue)
                {
                    ///Element = ReturnValue
                    saveFunctionXml.WriteStartElement("ReturnValue");

                    ///Attribute = Type
                    if (returnValue.Type != null)
                    {
                        saveFunctionXml.WriteAttributeString("Type", returnValue.Type.ToString());
                    }

                    ///Attribute = ValueOperator
                    if (returnValue.ValueOperator != null)
                    {
                        saveFunctionXml.WriteAttributeString("ValueOperator", returnValue.ValueOperator.ToString());
                    }

                    saveFunctionXml.WriteString(returnValue.NodeValue.ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                ///Element = Exception
                for (int indexException = 0; indexException < FunctionToSave.Exception.Count; indexException++)
                {
                    saveFunctionXml.WriteStartElement("Exception");
                    saveFunctionXml.WriteString(FunctionToSave.Exception[indexException].ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                /// Element = HelpLink
                saveFunctionXml.WriteStartElement("HelpLink");
                saveFunctionXml.WriteString(FunctionToSave.HelpLink.ToString());
                saveFunctionXml.WriteFullEndElement();

                /// Element = Param
                foreach (Parameter param in FunctionToSave.Parameter)
                {
                    ///Element = Param
                    saveFunctionXml.WriteStartElement("Param");

                    ///Attribute = Index
                    if (param.Index != -1)
                    {
                        saveFunctionXml.WriteAttributeString("Index", param.Index.ToString());
                    }

                    ///Attribute = Type
                    if (param.Type != null)
                    {
                        saveFunctionXml.WriteAttributeString("Type", param.Type.ToString());
                    }

                    ///Attribute = CompareAs
                    if (param.CompareAs != null)
                    {
                        saveFunctionXml.WriteAttributeString("CompareAs", param.CompareAs.ToString());
                    }

                    ///Attribute = Access
                    if (param.Access != null)
                    {
                        saveFunctionXml.WriteAttributeString("Access", param.Access.ToString());
                    }

                    ///Attribute = PointsToResource
                    if (param.PointsToResource != null)
                    {
                        saveFunctionXml.WriteAttributeString("PointsToResource", param.PointsToResource.ToString());
                    }

                    ///Attribute = ConcatWith
                    if (param.ConcatWith != null)
                    {
                        saveFunctionXml.WriteAttributeString("ConcatWith", param.ConcatWith.ToString());
                    }

                    ///Attribute = MapTo
                    if (param.MapTo != null)
                    {
                        saveFunctionXml.WriteAttributeString("MapTo", param.MapTo.ToString());
                    }

                    saveFunctionXml.WriteString(param.Name.ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                ///Element = ErrorCode
                foreach (ErrorCode errorCode in FunctionToSave.ErrorCode)
                {
                    ///Element = ErrorCode
                    saveFunctionXml.WriteStartElement("ErrorCode");

                    ///Attribute = IdentifyBy
                    if (errorCode.IdentifiedBy != null)
                    {
                        saveFunctionXml.WriteAttributeString("IdentifyBy", errorCode.IdentifiedBy.ToString());
                    }

                    ///Attribute = Type
                    if (errorCode.Type != null)
                    {
                        saveFunctionXml.WriteAttributeString("Type", errorCode.Type.ToString());
                    }

                    saveFunctionXml.WriteString(errorCode.NodeValue.ToString());
                    saveFunctionXml.WriteFullEndElement();
                }

                saveFunctionXml.WriteFullEndElement();
            }
            saveFunctionXml.WriteFullEndElement();

            //closing xmlwriter.
            saveFunctionXml.Close();
        }
Пример #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("This is Test Appliacation to test Functions.xml");
            try
            {
                FunctionXMLNavigator FuncXMLNav = new FunctionXMLNavigator();

                //enter the "Function.xml" path
                string FunctionXMLFilePath = @"E:\Fall2003\Holodeck xml files\holo 2.5\functions.xml";
                FuncXMLNav.ValidateXmlDocument(FunctionXMLFilePath);
                FuncXMLNav.parseXmlDocument(FunctionXMLFilePath);

                //modifying function here
                Function modifyThis = FuncXMLNav.GetFunctionByName( "bind" );

                //if function not found in original finctions.xml file then it we cannot modify it
                // nor we can add new function to the file
                if(modifyThis != null)
                {
                    modifyThis.OriginalDll = "TESTws2_32.dll";
                    modifyThis.InterceptedDll = "TESTws2_32replacementlibrary.dll";
                    modifyThis.ReplacementFunctionName = "TESTbindReplacement";
                    modifyThis.ReturnType = "TESTint";
                    modifyThis.Modifiers[0] = "TESTWINSOCK_API_LINKAGE";
                    modifyThis.Modifiers[1] = "TESTWSAAPI";
                    modifyThis.Category = "TESTNETWORK";

                    ReturnValue modifiedReturnValue_0 = new ReturnValue();
                    modifiedReturnValue_0.NodeValue = "TEST_0";
                    modifiedReturnValue_0.Type = "TEST_Success";
                    modifyThis.ReturnValue[0] = modifiedReturnValue_0;

                    ReturnValue modifiedReturnValue_1 = new ReturnValue();
                    modifiedReturnValue_1.NodeValue = "TEST_-1(SOCKET_ERROR)";
                    modifiedReturnValue_0.Type= "TEST_Error";
                    modifyThis.ReturnValue[1] = modifiedReturnValue_1;

                    modifyThis.HelpLink = @"TEST_http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/bind_2.asp";

                    Parameter modifiedParam = new Parameter();
                    modifiedParam.Name ="TESTs" ;
                    modifiedParam.Index = 01;
                    modifiedParam.Type ="TESTSOCKET" ;
                    modifiedParam.CompareAs ="TESTPointerType" ;
                    modifiedParam.Access ="TESTIN" ;
                    modifyThis.Parameter[0] = modifiedParam;

                    Parameter modifiedParam1 = new Parameter();
                    modifiedParam1.Name ="TESTname" ;
                    modifiedParam1.Index = 11;
                    modifiedParam1.Type ="TESTconst struct sockaddr FAR *" ;
                    modifiedParam1.CompareAs ="TESTPointerType" ;
                    modifiedParam1.Access ="TESTIN" ;
                    modifyThis.Parameter[1] = modifiedParam1;

                    Parameter modifiedParam2 = new Parameter();
                    modifiedParam2.Name = "TESTnamelen" ;
                    modifiedParam2.Index = 22;
                    modifiedParam2.Type ="TESTint" ;
                    modifiedParam2.CompareAs ="TESTIntegerType" ;
                    modifiedParam2.Access ="TESTIN" ;
                    modifyThis.Parameter[2] = modifiedParam2;

                    FuncXMLNav.UpdateFunctionByName("bind",modifyThis);
                }

                //saving the functions.xml
                FuncXMLNav.saveFunctionXmlDocument(FuncXMLNav,"functions.xml","",true);

                ///cannot use DotNetFunctions.xml as new version 2.5 file is not available.
                //			// DotNetFunctions.xml
                //			Console.WriteLine("This is Test Appliacation to test DotNetFunctions.xml");
                //			FunctionXMLNavigator DotNetFuncXMLNav = new FunctionXMLNavigator();
                //			string DotNetFunctionXMLFilePath = @"E:\Fall2003\Holodeck xml files\DotNetFunctions.xml";
                //			DotNetFuncXMLNav.parseXmlDocument(DotNetFunctionXMLFilePath);
                //			DotNetFuncXMLNav.saveFunctionXmlDocument(DotNetFuncXMLNav,"DotNetFunctions.xml");

            }

            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);
            }

            EditValues test = new EditValues();
            //string vp = "abc?ejj1@3%";
            string vp = "abc__ejj1@3%";
            Console.WriteLine(vp);
            Console.WriteLine(test.ToLower(vp));
            Console.WriteLine(test.ToUpper(vp));
            Console.WriteLine(test.InsertAtStart(vp,"pppp"));
            Console.WriteLine(test.InsetAtEnd(vp,"PPPP"));
            Console.WriteLine("SplitString:" +test.SplitString(vp));
            Console.WriteLine(test.SubstituteToNull(vp));
            foreach(string sp in test.SpecialCharacters)
            {
                Console.WriteLine(sp);

            }

            Console.WriteLine(test.changeEncodingToASCII(vp));
            Console.WriteLine(test.changeEncodingToUnicode(vp));
            Console.WriteLine(test.changeEncodingToUTF7(vp));
            Console.WriteLine(test.changeEncodingToUTF8(vp));
        }